Wrap an asynchronous middleware (or handler) function for Express, Connect, router, etc.
npm install async-middleware --save
Wrap a middleware function using async
and/or promises to catch errors and forward them to next(err)
.
var express = require('express')
var wrap = require('async-middleware').wrap
var app = express()
app.use(wrap(function (req, res) {
return Promise.reject(new Error('boom!'))
}))
MIT