express-rate-limit 7.5.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +292 -236
- package/dist/index.d.cts +56 -16
- package/dist/index.d.mts +56 -16
- package/dist/index.d.ts +56 -16
- package/dist/index.mjs +277 -232
- package/package.json +34 -54
- package/readme.md +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-rate-limit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Basic IP rate-limiting middleware for Express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Nathan Friedly",
|
|
@@ -56,78 +56,58 @@
|
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"clean": "del-cli dist/ coverage/ *.log *.tmp *.bak *.tgz",
|
|
59
|
-
"build:cjs": "esbuild --platform=node --bundle --target=es2022 --format=cjs --outfile=dist/index.cjs --footer:js=\"module.exports = rateLimit; module.exports.default = rateLimit; module.exports.rateLimit = rateLimit; module.exports.MemoryStore = MemoryStore;\" source/index.ts",
|
|
60
|
-
"build:esm": "esbuild --platform=node --bundle --target=es2022 --format=esm --outfile=dist/index.mjs source/index.ts",
|
|
59
|
+
"build:cjs": "esbuild --packages=external --platform=node --bundle --target=es2022 --format=cjs --outfile=dist/index.cjs --footer:js=\"module.exports = rateLimit; module.exports.default = rateLimit; module.exports.rateLimit = rateLimit; module.exports.MemoryStore = MemoryStore;\" source/index.ts",
|
|
60
|
+
"build:esm": "esbuild --packages=external --platform=node --bundle --target=es2022 --format=esm --outfile=dist/index.mjs source/index.ts",
|
|
61
61
|
"build:types": "dts-bundle-generator --out-file=dist/index.d.ts source/index.ts && cp dist/index.d.ts dist/index.d.cts && cp dist/index.d.ts dist/index.d.mts",
|
|
62
62
|
"compile": "run-s clean build:*",
|
|
63
63
|
"docs": "cd docs && mintlify dev",
|
|
64
|
-
"lint:code": "
|
|
65
|
-
"lint:
|
|
64
|
+
"lint:code": "biome check",
|
|
65
|
+
"lint:docs": "prettier --check docs/ *.md",
|
|
66
66
|
"lint": "run-s lint:*",
|
|
67
|
-
"format:code": "
|
|
68
|
-
"format:
|
|
67
|
+
"format:code": "biome check --write",
|
|
68
|
+
"format:docs": "prettier --write docs/ *.md",
|
|
69
69
|
"format": "run-s format:*",
|
|
70
70
|
"test:lib": "jest",
|
|
71
71
|
"test:ext": "cd test/external/ && bash run-all-tests",
|
|
72
72
|
"test": "run-s lint test:lib",
|
|
73
73
|
"pre-commit": "lint-staged",
|
|
74
|
-
"prepare": "run-s compile && husky
|
|
74
|
+
"prepare": "run-s compile && husky"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"ip": "2.0.1"
|
|
75
78
|
},
|
|
76
79
|
"peerDependencies": {
|
|
77
|
-
"express": "
|
|
80
|
+
"express": ">= 4.11"
|
|
78
81
|
},
|
|
79
82
|
"devDependencies": {
|
|
83
|
+
"@biomejs/biome": "2.1.1",
|
|
80
84
|
"@express-rate-limit/prettier": "1.1.1",
|
|
81
85
|
"@express-rate-limit/tsconfig": "1.0.2",
|
|
82
|
-
"@jest/globals": "
|
|
83
|
-
"@types/express": "
|
|
84
|
-
"@types/
|
|
85
|
-
"@types/
|
|
86
|
-
"@types/
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
86
|
+
"@jest/globals": "30.0.4",
|
|
87
|
+
"@types/express": "5.0.3",
|
|
88
|
+
"@types/ip": "1.1.3",
|
|
89
|
+
"@types/jest": "30.0.0",
|
|
90
|
+
"@types/node": "24.0.14",
|
|
91
|
+
"@types/supertest": "6.0.3",
|
|
92
|
+
"del-cli": "6.0.0",
|
|
93
|
+
"dts-bundle-generator": "9.5.1",
|
|
94
|
+
"esbuild": "0.25.6",
|
|
95
|
+
"express": "5.1.0",
|
|
96
|
+
"husky": "9.1.7",
|
|
97
|
+
"jest": "30.0.4",
|
|
98
|
+
"lint-staged": "16.1.2",
|
|
99
|
+
"mintlify": "4.2.15",
|
|
95
100
|
"npm-run-all": "4.1.5",
|
|
101
|
+
"prettier": "3.6.2",
|
|
96
102
|
"ratelimit-header-parser": "0.1.0",
|
|
97
|
-
"supertest": "
|
|
98
|
-
"ts-jest": "29.
|
|
99
|
-
"ts-node": "10.9.
|
|
100
|
-
"typescript": "5.
|
|
101
|
-
"xo": "0.56.0"
|
|
102
|
-
},
|
|
103
|
-
"xo": {
|
|
104
|
-
"prettier": true,
|
|
105
|
-
"rules": {
|
|
106
|
-
"@typescript-eslint/no-empty-function": 0,
|
|
107
|
-
"@typescript-eslint/no-dynamic-delete": 0,
|
|
108
|
-
"@typescript-eslint/no-confusing-void-expression": 0,
|
|
109
|
-
"@typescript-eslint/consistent-indexed-object-style": [
|
|
110
|
-
"error",
|
|
111
|
-
"index-signature"
|
|
112
|
-
],
|
|
113
|
-
"n/no-unsupported-features/es-syntax": 0
|
|
114
|
-
},
|
|
115
|
-
"overrides": [
|
|
116
|
-
{
|
|
117
|
-
"files": "test/library/*.ts",
|
|
118
|
-
"rules": {
|
|
119
|
-
"@typescript-eslint/no-unsafe-argument": 0,
|
|
120
|
-
"@typescript-eslint/no-unsafe-assignment": 0
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
],
|
|
124
|
-
"ignore": [
|
|
125
|
-
"test/external"
|
|
126
|
-
]
|
|
103
|
+
"supertest": "7.1.3",
|
|
104
|
+
"ts-jest": "29.4.0",
|
|
105
|
+
"ts-node": "10.9.2",
|
|
106
|
+
"typescript": "5.8.3"
|
|
127
107
|
},
|
|
128
108
|
"prettier": "@express-rate-limit/prettier",
|
|
129
109
|
"lint-staged": {
|
|
130
|
-
"{
|
|
131
|
-
"
|
|
110
|
+
"*.{js,ts,json}": "biome check --write",
|
|
111
|
+
"*.{md,yaml}": "prettier --write"
|
|
132
112
|
}
|
|
133
113
|
}
|
package/readme.md
CHANGED
|
@@ -28,6 +28,7 @@ const limiter = rateLimit({
|
|
|
28
28
|
limit: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes).
|
|
29
29
|
standardHeaders: 'draft-8', // draft-6: `RateLimit-*` headers; draft-7 & draft-8: combined `RateLimit` header
|
|
30
30
|
legacyHeaders: false, // Disable the `X-RateLimit-*` headers.
|
|
31
|
+
ipv6Subnet: 56, // Set to 60 or 64 to be less aggressive, or 52 or 48 to be more aggressive
|
|
31
32
|
// store: ... , // Redis, Memcached, etc. See below.
|
|
32
33
|
})
|
|
33
34
|
|
|
@@ -58,6 +59,7 @@ default values.
|
|
|
58
59
|
| [`store`] | `Store` | Use a custom store to share hit counts across multiple nodes. |
|
|
59
60
|
| [`passOnStoreError`] | `boolean` | Allow (`true`) or block (`false`, default) traffic if the store becomes unavailable. |
|
|
60
61
|
| [`keyGenerator`] | `function` | Identify users (defaults to IP address). |
|
|
62
|
+
| [`ipv6Subnet`] | `number` (32-64) \| `function` \| `false` | How many bits of IPv6 addresses to use in default `keyGenerator` |
|
|
61
63
|
| [`requestPropertyName`] | `string` | Add rate limit info to the `req` object. |
|
|
62
64
|
| [`skip`] | `function` | Return `true` to bypass the limiter for the given request. |
|
|
63
65
|
| [`skipSuccessfulRequests`] | `boolean` | Uncount 1xx/2xx/3xx responses. |
|
|
@@ -131,9 +133,11 @@ MIT © [Nathan Friedly](http://nfriedly.com/),
|
|
|
131
133
|
https://express-rate-limit.mintlify.app/reference/configuration#identifier
|
|
132
134
|
[`store`]: https://express-rate-limit.mintlify.app/reference/configuration#store
|
|
133
135
|
[`passOnStoreError`]:
|
|
134
|
-
https://express-rate-limit.mintlify.app/reference/configuration#
|
|
136
|
+
https://express-rate-limit.mintlify.app/reference/configuration#passonstoreerror
|
|
135
137
|
[`keyGenerator`]:
|
|
136
138
|
https://express-rate-limit.mintlify.app/reference/configuration#keygenerator
|
|
139
|
+
[`ipv6Subnet`]:
|
|
140
|
+
https://express-rate-limit.mintlify.app/reference/configuration#ipv6subnet
|
|
137
141
|
[`requestPropertyName`]:
|
|
138
142
|
https://express-rate-limit.mintlify.app/reference/configuration#requestpropertyname
|
|
139
143
|
[`skip`]: https://express-rate-limit.mintlify.app/reference/configuration#skip
|