httperrors
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -45,4 +45,14 @@ var createError = require('createerror'); | ||
var httpErrors = module.exports = {}; | ||
var httpErrors = module.exports = function (options) { | ||
if (typeof options === 'undefined') { | ||
options = {}; | ||
} else if (typeof options === 'number') { | ||
options = {statusCode: options}; | ||
} | ||
options.status = options.statusCode; | ||
return (httpErrors[options.statusCode] || httpErrors.Unknown)(options); | ||
}; | ||
httpErrors.Unknown = createError({name: 'Unknown'}); | ||
/// Map the error codes/names, as defined in Node's [http | ||
@@ -49,0 +59,0 @@ /// module](http://nodejs.org/docs/latest/api/http.html). |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"repository": { | ||
@@ -18,0 +18,0 @@ "type": "git", |
@@ -21,2 +21,5 @@ node-httperrors | ||
// Instatiate by status code: | ||
var myError = httpErrors(412); | ||
// Instantiate by name (UpperCamelCase): | ||
@@ -23,0 +26,0 @@ var err = new httpErrors.NotFound('The thing you were looking for was not found'); |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
74
2
59
0
5596