express-async-await
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -29,2 +29,14 @@ let expressaa = require('./index.js') | ||
app.get('/ok-middleware', function(req, res, next) { | ||
next(); | ||
}, async function(req, res, next) { | ||
res.json({hello: 'world'}) | ||
}) | ||
app.get('/no-middleware', function(req, res, next) { | ||
next(); | ||
}, async function(req, res, next) { | ||
throw new Error('123'); | ||
}) | ||
app.use((err, req, res, next) => { | ||
@@ -31,0 +43,0 @@ console.error(err) |
14
index.js
@@ -11,11 +11,15 @@ const wrapAsync = fn => (...args) => { | ||
app[m.toLowerCase()] = function(...args) { | ||
if (typeof args[1] === 'function') { | ||
args[1] = wrapAsync(args[1]) | ||
} | ||
const wrappedArgs = args.map(arg => { | ||
if (typeof arg === 'function') { | ||
return wrapAsync(arg); | ||
} | ||
return original.call(app, ...args) | ||
return arg; | ||
}); | ||
return original.call(app, ...wrappedArgs); | ||
} | ||
}) | ||
}); | ||
return app | ||
} |
{ | ||
"name": "express-async-await", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2881
55
4