diff --git a/HISTORY.md b/HISTORY.md index f04ec61..5f69004 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,7 @@ unreleased * Remove `Object.setPrototypeOf` polyfill * Use `Array.flat` instead of `array-flatten` package +* Replace `methods` dependency with standard library 2.0.0 / 2024-09-09 ================== diff --git a/lib/route.js b/lib/route.js index 5e9a778..6f1b7cd 100644 --- a/lib/route.js +++ b/lib/route.js @@ -13,7 +13,7 @@ */ const Layer = require('./layer') -const methods = require('methods') +const { METHODS } = require('node:http') /** * Module variables. @@ -215,6 +215,9 @@ Route.prototype.all = function all (handler) { return this } + +const methods = METHODS.map((method) => method.toLowerCase()) + methods.forEach(function (method) { Route.prototype[method] = function (handler) { const callbacks = flatten.call(slice.call(arguments), Infinity) diff --git a/package.json b/package.json index de23500..cbbba3b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "repository": "pillarjs/router", "dependencies": { "is-promise": "4.0.0", - "methods": "~1.1.2", "parseurl": "~1.3.3", "path-to-regexp": "^8.0.0", "utils-merge": "1.0.1"