Skip to content

Commit 878b0e0

Browse files
authored
refactor: replace methods dependency with standard library (#127)
1 parent 36ae18f commit 878b0e0

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

HISTORY.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ unreleased
33

44
* Remove `Object.setPrototypeOf` polyfill
55
* Use `Array.flat` instead of `array-flatten` package
6+
* Replace `methods` dependency with standard library
67

78
2.0.0 / 2024-09-09
89
==================

lib/route.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
const Layer = require('./layer')
16-
const methods = require('methods')
16+
const { METHODS } = require('node:http')
1717

1818
/**
1919
* Module variables.
@@ -215,6 +215,9 @@ Route.prototype.all = function all (handler) {
215215
return this
216216
}
217217

218+
219+
const methods = METHODS.map((method) => method.toLowerCase())
220+
218221
methods.forEach(function (method) {
219222
Route.prototype[method] = function (handler) {
220223
const callbacks = flatten.call(slice.call(arguments), Infinity)

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"repository": "pillarjs/router",
1111
"dependencies": {
1212
"is-promise": "4.0.0",
13-
"methods": "~1.1.2",
1413
"parseurl": "~1.3.3",
1514
"path-to-regexp": "^8.0.0",
1615
"utils-merge": "1.0.1"

0 commit comments

Comments
 (0)