allow-methods
Advanced tools
Comparing version 5.0.1 to 5.0.2
'use strict'; | ||
const httpError = require('http-errors'); | ||
class MethodNotAllowedError extends Error { | ||
/** @type {string} */ | ||
name = 'MethodNotAllowedError'; | ||
/** @type {number} */ | ||
status = 405; | ||
/** @type {number} */ | ||
statusCode = 405; | ||
} | ||
/** | ||
@@ -9,3 +20,3 @@ * Create an Express middleware function which errors if an HTTP method is not allowed. | ||
* @public | ||
* @param {Array<string>} [methods=[]] | ||
* @param {string[]} [methods] | ||
* The HTTP methods which will not throw 405 errors. | ||
@@ -22,3 +33,3 @@ * @param {string} [message] | ||
response.header('Allow', normalizedMethods.join(', ')); | ||
return next(httpError(405, message)); | ||
return next(new MethodNotAllowedError(message)); | ||
} | ||
@@ -33,5 +44,5 @@ next(); | ||
* @private | ||
* @param {Array<string>} methods | ||
* @param {string[]} methods | ||
* The HTTP methods to normalise. | ||
* @returns {Array<string>} | ||
* @returns {string[]} | ||
* Returns an array of capitalised HTTP methods. | ||
@@ -38,0 +49,0 @@ */ |
{ | ||
"name": "allow-methods", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Express/connect middleware to handle 405 errors", | ||
@@ -39,12 +39,8 @@ "keywords": [ | ||
}, | ||
"dependencies": { | ||
"http-errors": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^17.0.0", | ||
"@commitlint/config-conventional": "^17.0.0", | ||
"@rowanmanning/eslint-config": "^6.0.0", | ||
"@rowanmanning/eslint-config": "^7.0.0", | ||
"@types/express": "^4.17.13", | ||
"axios": "^1.0.0", | ||
"chai": "^4.3.6", | ||
"eslint": "^8.9.0", | ||
@@ -70,2 +66,2 @@ "express4": "npm:express@^4.17.3", | ||
} | ||
} | ||
} |
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
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
7572
0
13
82
0
- Removedhttp-errors@^2.0.0
- Removeddepd@2.0.0(transitive)
- Removedhttp-errors@2.0.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedstatuses@2.0.1(transitive)
- Removedtoidentifier@1.0.1(transitive)