express-router-api
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -68,4 +68,2 @@ 'use strict'; | ||
return (req, res, next) => { | ||
let returnValue = origHandler(req, res, next); | ||
let apiErrorHandler = err => { | ||
@@ -76,3 +74,4 @@ res.status(err.statusCode || 500).json(err.message); | ||
Promise.resolve().then(() => { | ||
Promise.resolve().then(() => origHandler(req, res, next)) | ||
.then((returnValue) => { | ||
if(typeof returnValue === 'undefined' && index === callbacks.length - 1) { | ||
@@ -79,0 +78,0 @@ throw new ExpressApiRouterError('Route for ' + path.toString() + ' did not return a promise'); |
{ | ||
"name": "express-router-api", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
10
test.js
@@ -156,2 +156,12 @@ 'use strict'; | ||
routeTest((req, res) => { | ||
throw new ApiError({error: 'test'}, 403); | ||
}); | ||
return requestTest({ | ||
error: 'test' | ||
}, 403) | ||
}); | ||
it('should support reporting JSON errors from promise', () => { | ||
routeTest((req, res) => { | ||
return Promise.delay(10).then(() => { | ||
@@ -158,0 +168,0 @@ throw new ApiError({error: 'test'}, 403); |
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
11163
297