
Research
/Security News
737 Chrome VPN Extensions Linked to Brand Impersonation and Browser Traffic Redirection
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.
express-yields-2
Advanced tools
A dead simple ES6 generators support hack for ExpressJS
npm install express-yields --save
Then require this script somewhere before you start using it:
const express = require('express');
const yields = require('express-yields');
const User = require('./models/user');
const app = express();
app.get('/users', function* (req, res) {
const users = yield User.findAll(); // <- some Promise
res.send(users);
});
nextAs we all know express sends a function called next into the middleware, which
then needs to be called with or without error to make it move the request handling
to the next middleware. It still works, but in case of a generator function, you
don't need to do that. If you want to pass an error, just throw a normal exception:
app.use(function * (req, res) {
const user = yield User.findByToken(req.get('authorization'));
if (!user) throw Error("access denied");
});
This is a very minimalistic and unintrusive hack. Instead of patching all methods
on an express Router, it wraps the Layer#handle property in one place, leaving
all the rest of the express guts intact.
The idea is that you require the patch once and then use the 'express' lib the
usual way in the rest of your application.
All code in this repository is released under the terms of the ISC license.
Copyright (C) 2016 Nikolay Nemshilov
FAQs
ES6 generators and async functions support for expressjs
We found that express-yields-2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.