Comparing version 0.7.9 to 0.7.10-beta.2
@@ -0,0 +0,0 @@ # Nodecaf Changelog |
@@ -9,16 +9,21 @@ const createError = require('http-errors'); | ||
module.exports = { | ||
NotFound: msg => composeError('NotFound', 404, msg), | ||
Unauthorized: msg => composeError('Unauthorized', 401, msg), | ||
ServerFault: msg => composeError('ServerFault', 500, msg), | ||
InvalidActionForState: msg => composeError('InvalidActionForState', 405, msg), | ||
InvalidCredentials: msg => composeError('InvalidCredentials', 400, msg), | ||
InvalidContent: msg => composeError('InvalidContent', 400, msg), | ||
BadRequest: msg => composeError('BadRequest', 400, msg), | ||
const ERRORS = { | ||
NotFound: 404, | ||
Unauthorized: 401, | ||
ServerFault: 500, | ||
InvalidActionForState: 405, | ||
InvalidCredentials: 400, | ||
InvalidContent: 400, | ||
BadRequest: 400 | ||
} | ||
parse(err, msg){ | ||
if(typeof this[err] == 'function') | ||
err = this[err](msg || err); | ||
return err; | ||
module.exports = new Proxy({}, { | ||
has(target, key){ | ||
return key in ERRORS; | ||
}, | ||
get(target, prop){ | ||
return msg => composeError(prop, ERRORS[prop], msg); | ||
} | ||
}; | ||
}); |
@@ -8,2 +8,8 @@ const assert = require('assert'); | ||
function parseError(err, msg){ | ||
if(err in errors) | ||
err = errors[err](msg || err); | ||
return err; | ||
} | ||
function parseContentType(req){ | ||
@@ -58,3 +64,3 @@ try{ | ||
// this => app | ||
err = errors.parse(err, msg); | ||
err = parseError(err, msg); | ||
input.next(err); | ||
@@ -90,3 +96,3 @@ } | ||
// this => Response object | ||
this.err = errors.parse(err, msg); | ||
this.err = parseError(err, msg); | ||
} | ||
@@ -122,2 +128,3 @@ | ||
defaultErrorHandler(err, req, res, next){ | ||
let original = err; | ||
@@ -147,4 +154,4 @@ // Run user error handler. | ||
if(err.status == 500) | ||
this.log.error({ req: req, err: err }, 'UNCAUGHT ROUTE ERROR'); | ||
this.log.error({ req: req, err: original }, 'UNCAUGHT ROUTE ERROR'); | ||
} | ||
} |
{ | ||
"name": "nodecaf", | ||
"version": "0.7.9", | ||
"version": "0.7.10-beta.2", | ||
"description": "Nodecaf is an Express framework for developing REST APIs in a quick and convenient manner.", | ||
@@ -37,3 +37,3 @@ "main": "lib/main.js", | ||
"compression": "^1.7.4", | ||
"confort": "^0.1.2", | ||
"confort": "^0.1.3-beta.2", | ||
"cookie-parser": "^1.4.4", | ||
@@ -40,0 +40,0 @@ "cors": "^2.8.5", |
@@ -0,0 +0,0 @@ # [Nodecaf](https://gitlab.com/GCSBOSS/nodecaf) |
filefoobar |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
79015
1233
1
Updatedconfort@^0.1.3-beta.2