express-rate-limit 7.2.0 → 7.3.1
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 +34 -9
- package/dist/index.d.cts +16 -8
- package/dist/index.d.mts +16 -8
- package/dist/index.d.ts +16 -8
- package/dist/index.mjs +34 -9
- package/package.json +2 -2
- package/readme.md +55 -18
package/dist/index.cjs
CHANGED
|
@@ -99,6 +99,7 @@ var ValidationError = class extends Error {
|
|
|
99
99
|
};
|
|
100
100
|
var ChangeWarning = class extends ValidationError {
|
|
101
101
|
};
|
|
102
|
+
var usedStores = /* @__PURE__ */ new Set();
|
|
102
103
|
var singleCountKeys = /* @__PURE__ */ new WeakMap();
|
|
103
104
|
var validations = {
|
|
104
105
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
@@ -182,6 +183,19 @@ var validations = {
|
|
|
182
183
|
);
|
|
183
184
|
}
|
|
184
185
|
},
|
|
186
|
+
/**
|
|
187
|
+
* Ensures a single store instance is not used with multiple express-rate-limit instances
|
|
188
|
+
*/
|
|
189
|
+
unsharedStore(store) {
|
|
190
|
+
if (usedStores.has(store)) {
|
|
191
|
+
const maybeUniquePrefix = store?.localKeys ? "" : " (with a unique prefix)";
|
|
192
|
+
throw new ValidationError(
|
|
193
|
+
"ERR_ERL_STORE_REUSE",
|
|
194
|
+
`A Store instance must not be shared across multiple rate limiters. Create a new instance of ${store.constructor.name}${maybeUniquePrefix} for each limiter instead.`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
usedStores.add(store);
|
|
198
|
+
},
|
|
185
199
|
/**
|
|
186
200
|
* Ensures a given key is incremented only once per request.
|
|
187
201
|
*
|
|
@@ -213,8 +227,8 @@ var validations = {
|
|
|
213
227
|
keys.push(prefixedKey);
|
|
214
228
|
},
|
|
215
229
|
/**
|
|
216
|
-
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
217
|
-
* major release.
|
|
230
|
+
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
231
|
+
* changing in the next major release.
|
|
218
232
|
*
|
|
219
233
|
* @param limit {number} - The maximum number of hits per client.
|
|
220
234
|
*
|
|
@@ -245,8 +259,8 @@ var validations = {
|
|
|
245
259
|
}
|
|
246
260
|
},
|
|
247
261
|
/**
|
|
248
|
-
* Warns the user that the `onLimitReached` option is deprecated and
|
|
249
|
-
* major release.
|
|
262
|
+
* Warns the user that the `onLimitReached` option is deprecated and
|
|
263
|
+
* will be removed in the next major release.
|
|
250
264
|
*
|
|
251
265
|
* @param onLimitReached {any | undefined} - The maximum number of hits per client.
|
|
252
266
|
*
|
|
@@ -277,9 +291,11 @@ var validations = {
|
|
|
277
291
|
}
|
|
278
292
|
},
|
|
279
293
|
/**
|
|
280
|
-
* Checks the options.validate setting to ensure that only recognized
|
|
294
|
+
* Checks the options.validate setting to ensure that only recognized
|
|
295
|
+
* validations are enabled or disabled.
|
|
281
296
|
*
|
|
282
|
-
* If any unrecognized values are found, an error is logged that
|
|
297
|
+
* If any unrecognized values are found, an error is logged that
|
|
298
|
+
* includes the list of supported vaidations.
|
|
283
299
|
*/
|
|
284
300
|
validationsConfig() {
|
|
285
301
|
const supportedValidations = Object.keys(this).filter(
|
|
@@ -298,13 +314,21 @@ var validations = {
|
|
|
298
314
|
}
|
|
299
315
|
},
|
|
300
316
|
/**
|
|
301
|
-
* Checks to see if the instance was created inside of a request handler,
|
|
317
|
+
* Checks to see if the instance was created inside of a request handler,
|
|
318
|
+
* which would prevent it from working correctly, with the default memory
|
|
319
|
+
* store (or any other store with localKeys.)
|
|
302
320
|
*/
|
|
303
|
-
creationStack() {
|
|
321
|
+
creationStack(store) {
|
|
304
322
|
const { stack } = new Error(
|
|
305
323
|
"express-rate-limit validation check (set options.validate.creationStack=false to disable)"
|
|
306
324
|
);
|
|
307
325
|
if (stack?.includes("Layer.handle [as handle_request]")) {
|
|
326
|
+
if (!store.localKeys) {
|
|
327
|
+
throw new ValidationError(
|
|
328
|
+
"ERR_ERL_CREATED_IN_REQUEST_HANDLER",
|
|
329
|
+
"express-rate-limit instance should *usually* be created at app initialization, not when responding to a request."
|
|
330
|
+
);
|
|
331
|
+
}
|
|
308
332
|
throw new ValidationError(
|
|
309
333
|
"ERR_ERL_CREATED_IN_REQUEST_HANDLER",
|
|
310
334
|
`express-rate-limit instance should be created at app initialization, not when responding to a request.`
|
|
@@ -630,7 +654,8 @@ var handleAsyncErrors = (fn) => async (request, response, next) => {
|
|
|
630
654
|
var rateLimit = (passedOptions) => {
|
|
631
655
|
const config = parseOptions(passedOptions ?? {});
|
|
632
656
|
const options = getOptionsFromConfig(config);
|
|
633
|
-
config.validations.creationStack();
|
|
657
|
+
config.validations.creationStack(config.store);
|
|
658
|
+
config.validations.unsharedStore(config.store);
|
|
634
659
|
if (typeof config.store.init === "function")
|
|
635
660
|
config.store.init(options);
|
|
636
661
|
const middleware = handleAsyncErrors(
|
package/dist/index.d.cts
CHANGED
|
@@ -45,6 +45,10 @@ declare const validations: {
|
|
|
45
45
|
* @param hits {any} - The `totalHits` returned by the store.
|
|
46
46
|
*/
|
|
47
47
|
positiveHits(hits: any): void;
|
|
48
|
+
/**
|
|
49
|
+
* Ensures a single store instance is not used with multiple express-rate-limit instances
|
|
50
|
+
*/
|
|
51
|
+
unsharedStore(store: Store): void;
|
|
48
52
|
/**
|
|
49
53
|
* Ensures a given key is incremented only once per request.
|
|
50
54
|
*
|
|
@@ -56,8 +60,8 @@ declare const validations: {
|
|
|
56
60
|
*/
|
|
57
61
|
singleCount(request: Request, store: Store, key: string): void;
|
|
58
62
|
/**
|
|
59
|
-
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
60
|
-
* major release.
|
|
63
|
+
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
64
|
+
* changing in the next major release.
|
|
61
65
|
*
|
|
62
66
|
* @param limit {number} - The maximum number of hits per client.
|
|
63
67
|
*
|
|
@@ -74,8 +78,8 @@ declare const validations: {
|
|
|
74
78
|
*/
|
|
75
79
|
draftPolliHeaders(draft_polli_ratelimit_headers?: any): void;
|
|
76
80
|
/**
|
|
77
|
-
* Warns the user that the `onLimitReached` option is deprecated and
|
|
78
|
-
* major release.
|
|
81
|
+
* Warns the user that the `onLimitReached` option is deprecated and
|
|
82
|
+
* will be removed in the next major release.
|
|
79
83
|
*
|
|
80
84
|
* @param onLimitReached {any | undefined} - The maximum number of hits per client.
|
|
81
85
|
*
|
|
@@ -92,15 +96,19 @@ declare const validations: {
|
|
|
92
96
|
*/
|
|
93
97
|
headersResetTime(resetTime?: Date): void;
|
|
94
98
|
/**
|
|
95
|
-
* Checks the options.validate setting to ensure that only recognized
|
|
99
|
+
* Checks the options.validate setting to ensure that only recognized
|
|
100
|
+
* validations are enabled or disabled.
|
|
96
101
|
*
|
|
97
|
-
* If any unrecognized values are found, an error is logged that
|
|
102
|
+
* If any unrecognized values are found, an error is logged that
|
|
103
|
+
* includes the list of supported vaidations.
|
|
98
104
|
*/
|
|
99
105
|
validationsConfig(): void;
|
|
100
106
|
/**
|
|
101
|
-
* Checks to see if the instance was created inside of a request handler,
|
|
107
|
+
* Checks to see if the instance was created inside of a request handler,
|
|
108
|
+
* which would prevent it from working correctly, with the default memory
|
|
109
|
+
* store (or any other store with localKeys.)
|
|
102
110
|
*/
|
|
103
|
-
creationStack(): void;
|
|
111
|
+
creationStack(store: Store): void;
|
|
104
112
|
};
|
|
105
113
|
export type Validations = typeof validations;
|
|
106
114
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -45,6 +45,10 @@ declare const validations: {
|
|
|
45
45
|
* @param hits {any} - The `totalHits` returned by the store.
|
|
46
46
|
*/
|
|
47
47
|
positiveHits(hits: any): void;
|
|
48
|
+
/**
|
|
49
|
+
* Ensures a single store instance is not used with multiple express-rate-limit instances
|
|
50
|
+
*/
|
|
51
|
+
unsharedStore(store: Store): void;
|
|
48
52
|
/**
|
|
49
53
|
* Ensures a given key is incremented only once per request.
|
|
50
54
|
*
|
|
@@ -56,8 +60,8 @@ declare const validations: {
|
|
|
56
60
|
*/
|
|
57
61
|
singleCount(request: Request, store: Store, key: string): void;
|
|
58
62
|
/**
|
|
59
|
-
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
60
|
-
* major release.
|
|
63
|
+
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
64
|
+
* changing in the next major release.
|
|
61
65
|
*
|
|
62
66
|
* @param limit {number} - The maximum number of hits per client.
|
|
63
67
|
*
|
|
@@ -74,8 +78,8 @@ declare const validations: {
|
|
|
74
78
|
*/
|
|
75
79
|
draftPolliHeaders(draft_polli_ratelimit_headers?: any): void;
|
|
76
80
|
/**
|
|
77
|
-
* Warns the user that the `onLimitReached` option is deprecated and
|
|
78
|
-
* major release.
|
|
81
|
+
* Warns the user that the `onLimitReached` option is deprecated and
|
|
82
|
+
* will be removed in the next major release.
|
|
79
83
|
*
|
|
80
84
|
* @param onLimitReached {any | undefined} - The maximum number of hits per client.
|
|
81
85
|
*
|
|
@@ -92,15 +96,19 @@ declare const validations: {
|
|
|
92
96
|
*/
|
|
93
97
|
headersResetTime(resetTime?: Date): void;
|
|
94
98
|
/**
|
|
95
|
-
* Checks the options.validate setting to ensure that only recognized
|
|
99
|
+
* Checks the options.validate setting to ensure that only recognized
|
|
100
|
+
* validations are enabled or disabled.
|
|
96
101
|
*
|
|
97
|
-
* If any unrecognized values are found, an error is logged that
|
|
102
|
+
* If any unrecognized values are found, an error is logged that
|
|
103
|
+
* includes the list of supported vaidations.
|
|
98
104
|
*/
|
|
99
105
|
validationsConfig(): void;
|
|
100
106
|
/**
|
|
101
|
-
* Checks to see if the instance was created inside of a request handler,
|
|
107
|
+
* Checks to see if the instance was created inside of a request handler,
|
|
108
|
+
* which would prevent it from working correctly, with the default memory
|
|
109
|
+
* store (or any other store with localKeys.)
|
|
102
110
|
*/
|
|
103
|
-
creationStack(): void;
|
|
111
|
+
creationStack(store: Store): void;
|
|
104
112
|
};
|
|
105
113
|
export type Validations = typeof validations;
|
|
106
114
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,10 @@ declare const validations: {
|
|
|
45
45
|
* @param hits {any} - The `totalHits` returned by the store.
|
|
46
46
|
*/
|
|
47
47
|
positiveHits(hits: any): void;
|
|
48
|
+
/**
|
|
49
|
+
* Ensures a single store instance is not used with multiple express-rate-limit instances
|
|
50
|
+
*/
|
|
51
|
+
unsharedStore(store: Store): void;
|
|
48
52
|
/**
|
|
49
53
|
* Ensures a given key is incremented only once per request.
|
|
50
54
|
*
|
|
@@ -56,8 +60,8 @@ declare const validations: {
|
|
|
56
60
|
*/
|
|
57
61
|
singleCount(request: Request, store: Store, key: string): void;
|
|
58
62
|
/**
|
|
59
|
-
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
60
|
-
* major release.
|
|
63
|
+
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
64
|
+
* changing in the next major release.
|
|
61
65
|
*
|
|
62
66
|
* @param limit {number} - The maximum number of hits per client.
|
|
63
67
|
*
|
|
@@ -74,8 +78,8 @@ declare const validations: {
|
|
|
74
78
|
*/
|
|
75
79
|
draftPolliHeaders(draft_polli_ratelimit_headers?: any): void;
|
|
76
80
|
/**
|
|
77
|
-
* Warns the user that the `onLimitReached` option is deprecated and
|
|
78
|
-
* major release.
|
|
81
|
+
* Warns the user that the `onLimitReached` option is deprecated and
|
|
82
|
+
* will be removed in the next major release.
|
|
79
83
|
*
|
|
80
84
|
* @param onLimitReached {any | undefined} - The maximum number of hits per client.
|
|
81
85
|
*
|
|
@@ -92,15 +96,19 @@ declare const validations: {
|
|
|
92
96
|
*/
|
|
93
97
|
headersResetTime(resetTime?: Date): void;
|
|
94
98
|
/**
|
|
95
|
-
* Checks the options.validate setting to ensure that only recognized
|
|
99
|
+
* Checks the options.validate setting to ensure that only recognized
|
|
100
|
+
* validations are enabled or disabled.
|
|
96
101
|
*
|
|
97
|
-
* If any unrecognized values are found, an error is logged that
|
|
102
|
+
* If any unrecognized values are found, an error is logged that
|
|
103
|
+
* includes the list of supported vaidations.
|
|
98
104
|
*/
|
|
99
105
|
validationsConfig(): void;
|
|
100
106
|
/**
|
|
101
|
-
* Checks to see if the instance was created inside of a request handler,
|
|
107
|
+
* Checks to see if the instance was created inside of a request handler,
|
|
108
|
+
* which would prevent it from working correctly, with the default memory
|
|
109
|
+
* store (or any other store with localKeys.)
|
|
102
110
|
*/
|
|
103
|
-
creationStack(): void;
|
|
111
|
+
creationStack(store: Store): void;
|
|
104
112
|
};
|
|
105
113
|
export type Validations = typeof validations;
|
|
106
114
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -71,6 +71,7 @@ var ValidationError = class extends Error {
|
|
|
71
71
|
};
|
|
72
72
|
var ChangeWarning = class extends ValidationError {
|
|
73
73
|
};
|
|
74
|
+
var usedStores = /* @__PURE__ */ new Set();
|
|
74
75
|
var singleCountKeys = /* @__PURE__ */ new WeakMap();
|
|
75
76
|
var validations = {
|
|
76
77
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
@@ -154,6 +155,19 @@ var validations = {
|
|
|
154
155
|
);
|
|
155
156
|
}
|
|
156
157
|
},
|
|
158
|
+
/**
|
|
159
|
+
* Ensures a single store instance is not used with multiple express-rate-limit instances
|
|
160
|
+
*/
|
|
161
|
+
unsharedStore(store) {
|
|
162
|
+
if (usedStores.has(store)) {
|
|
163
|
+
const maybeUniquePrefix = store?.localKeys ? "" : " (with a unique prefix)";
|
|
164
|
+
throw new ValidationError(
|
|
165
|
+
"ERR_ERL_STORE_REUSE",
|
|
166
|
+
`A Store instance must not be shared across multiple rate limiters. Create a new instance of ${store.constructor.name}${maybeUniquePrefix} for each limiter instead.`
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
usedStores.add(store);
|
|
170
|
+
},
|
|
157
171
|
/**
|
|
158
172
|
* Ensures a given key is incremented only once per request.
|
|
159
173
|
*
|
|
@@ -185,8 +199,8 @@ var validations = {
|
|
|
185
199
|
keys.push(prefixedKey);
|
|
186
200
|
},
|
|
187
201
|
/**
|
|
188
|
-
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
189
|
-
* major release.
|
|
202
|
+
* Warns the user that the behaviour for `max: 0` / `limit: 0` is
|
|
203
|
+
* changing in the next major release.
|
|
190
204
|
*
|
|
191
205
|
* @param limit {number} - The maximum number of hits per client.
|
|
192
206
|
*
|
|
@@ -217,8 +231,8 @@ var validations = {
|
|
|
217
231
|
}
|
|
218
232
|
},
|
|
219
233
|
/**
|
|
220
|
-
* Warns the user that the `onLimitReached` option is deprecated and
|
|
221
|
-
* major release.
|
|
234
|
+
* Warns the user that the `onLimitReached` option is deprecated and
|
|
235
|
+
* will be removed in the next major release.
|
|
222
236
|
*
|
|
223
237
|
* @param onLimitReached {any | undefined} - The maximum number of hits per client.
|
|
224
238
|
*
|
|
@@ -249,9 +263,11 @@ var validations = {
|
|
|
249
263
|
}
|
|
250
264
|
},
|
|
251
265
|
/**
|
|
252
|
-
* Checks the options.validate setting to ensure that only recognized
|
|
266
|
+
* Checks the options.validate setting to ensure that only recognized
|
|
267
|
+
* validations are enabled or disabled.
|
|
253
268
|
*
|
|
254
|
-
* If any unrecognized values are found, an error is logged that
|
|
269
|
+
* If any unrecognized values are found, an error is logged that
|
|
270
|
+
* includes the list of supported vaidations.
|
|
255
271
|
*/
|
|
256
272
|
validationsConfig() {
|
|
257
273
|
const supportedValidations = Object.keys(this).filter(
|
|
@@ -270,13 +286,21 @@ var validations = {
|
|
|
270
286
|
}
|
|
271
287
|
},
|
|
272
288
|
/**
|
|
273
|
-
* Checks to see if the instance was created inside of a request handler,
|
|
289
|
+
* Checks to see if the instance was created inside of a request handler,
|
|
290
|
+
* which would prevent it from working correctly, with the default memory
|
|
291
|
+
* store (or any other store with localKeys.)
|
|
274
292
|
*/
|
|
275
|
-
creationStack() {
|
|
293
|
+
creationStack(store) {
|
|
276
294
|
const { stack } = new Error(
|
|
277
295
|
"express-rate-limit validation check (set options.validate.creationStack=false to disable)"
|
|
278
296
|
);
|
|
279
297
|
if (stack?.includes("Layer.handle [as handle_request]")) {
|
|
298
|
+
if (!store.localKeys) {
|
|
299
|
+
throw new ValidationError(
|
|
300
|
+
"ERR_ERL_CREATED_IN_REQUEST_HANDLER",
|
|
301
|
+
"express-rate-limit instance should *usually* be created at app initialization, not when responding to a request."
|
|
302
|
+
);
|
|
303
|
+
}
|
|
280
304
|
throw new ValidationError(
|
|
281
305
|
"ERR_ERL_CREATED_IN_REQUEST_HANDLER",
|
|
282
306
|
`express-rate-limit instance should be created at app initialization, not when responding to a request.`
|
|
@@ -602,7 +626,8 @@ var handleAsyncErrors = (fn) => async (request, response, next) => {
|
|
|
602
626
|
var rateLimit = (passedOptions) => {
|
|
603
627
|
const config = parseOptions(passedOptions ?? {});
|
|
604
628
|
const options = getOptionsFromConfig(config);
|
|
605
|
-
config.validations.creationStack();
|
|
629
|
+
config.validations.creationStack(config.store);
|
|
630
|
+
config.validations.unsharedStore(config.store);
|
|
606
631
|
if (typeof config.store.init === "function")
|
|
607
632
|
config.store.init(options);
|
|
608
633
|
const middleware = handleAsyncErrors(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-rate-limit",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1",
|
|
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",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"del-cli": "5.1.0",
|
|
88
88
|
"dts-bundle-generator": "8.0.1",
|
|
89
89
|
"esbuild": "0.19.5",
|
|
90
|
-
"express": "4.
|
|
90
|
+
"express": "4.19.2",
|
|
91
91
|
"husky": "8.0.3",
|
|
92
92
|
"jest": "29.7.0",
|
|
93
93
|
"lint-staged": "15.0.2",
|
package/readme.md
CHANGED
|
@@ -45,23 +45,23 @@ The rate limiter comes with a built-in memory store, and supports a variety of
|
|
|
45
45
|
All function options may be async. Click the name for additional info and
|
|
46
46
|
default values.
|
|
47
47
|
|
|
48
|
-
| Option
|
|
49
|
-
|
|
|
50
|
-
| [`windowMs`]
|
|
51
|
-
| [`limit`]
|
|
52
|
-
| [`message`]
|
|
53
|
-
| [`statusCode`]
|
|
54
|
-
| [`
|
|
55
|
-
| [`
|
|
56
|
-
| [`
|
|
57
|
-
| [`
|
|
58
|
-
| [`
|
|
59
|
-
| [`
|
|
60
|
-
| [`
|
|
61
|
-
| [`
|
|
62
|
-
| [`
|
|
63
|
-
| [`
|
|
64
|
-
| [`
|
|
48
|
+
| Option | Type | Remarks |
|
|
49
|
+
| -------------------------- | -------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
50
|
+
| [`windowMs`] | `number` | How long to remember requests for, in milliseconds. |
|
|
51
|
+
| [`limit`] | `number` \| `function` | How many requests to allow. |
|
|
52
|
+
| [`message`] | `string` \| `json` \| `function` | Response to return after limit is reached. |
|
|
53
|
+
| [`statusCode`] | `number` | HTTP status code after limit is reached (default is 429). |
|
|
54
|
+
| [`handler`] | `function` | Function to run after limit is reached (overrides `message` and `statusCode` settings, if set). |
|
|
55
|
+
| [`legacyHeaders`] | `boolean` | Enable the `X-Rate-Limit` header. |
|
|
56
|
+
| [`standardHeaders`] | `'draft-6'` \| `'draft-7'` | Enable the `Ratelimit` header. |
|
|
57
|
+
| [`store`] | `Store` | Use a custom store to share hit counts across multiple nodes. |
|
|
58
|
+
| [`keyGenerator`] | `function` | Identify users (defaults to IP address). |
|
|
59
|
+
| [`requestPropertyName`] | `string` | Add rate limit info to the `req` object. |
|
|
60
|
+
| [`skip`] | `function` | Return `true` to bypass the limiter for the given request. |
|
|
61
|
+
| [`skipSuccessfulRequests`] | `boolean` | Uncount 1xx/2xx/3xx responses. |
|
|
62
|
+
| [`skipFailedRequests`] | `boolean` | Uncount 4xx/5xx responses. |
|
|
63
|
+
| [`requestWasSuccessful`] | `function` | Used by `skipSuccessfulRequests` and `skipFailedRequests`. |
|
|
64
|
+
| [`validate`] | `boolean` \| `object` | Enable or disable built-in validation checks. |
|
|
65
65
|
|
|
66
66
|
## Thank You
|
|
67
67
|
|
|
@@ -71,6 +71,15 @@ Gateway for developers. Add
|
|
|
71
71
|
authentication and more to any API in minutes. Learn more at
|
|
72
72
|
[zuplo.com](https://zuplo.link/express-rate-limit)
|
|
73
73
|
|
|
74
|
+
<p align="center">
|
|
75
|
+
<a href="https://zuplo.link/express-rate-limit">
|
|
76
|
+
<picture width="322">
|
|
77
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/express-rate-limit/express-rate-limit/assets/114976/cd2f6fa7-eae1-4fbb-be7d-b17df4c6f383">
|
|
78
|
+
<img alt="zuplo-logo" src="https://github.com/express-rate-limit/express-rate-limit/assets/114976/66fd75fa-b39e-4a8c-8d7a-52369bf244dc" width="322">
|
|
79
|
+
</picture>
|
|
80
|
+
</a>
|
|
81
|
+
</p>
|
|
82
|
+
|
|
74
83
|
---
|
|
75
84
|
|
|
76
85
|
Thanks to Mintlify for hosting the documentation at
|
|
@@ -90,7 +99,7 @@ Finally, thank you to everyone who's contributed to this project in any way!
|
|
|
90
99
|
|
|
91
100
|
If you encounter a bug or want to see something added/changed, please go ahead
|
|
92
101
|
and
|
|
93
|
-
[open an issue](https://github.com/
|
|
102
|
+
[open an issue](https://github.com/express-rate-limit/express-rate-limit/issues/new)!
|
|
94
103
|
If you need help with something, feel free to
|
|
95
104
|
[start a discussion](https://github.com/express-rate-limit/express-rate-limit/discussions/new)!
|
|
96
105
|
|
|
@@ -102,3 +111,31 @@ Then you can pick up any issue and fix/implement it!
|
|
|
102
111
|
|
|
103
112
|
MIT © [Nathan Friedly](http://nfriedly.com/),
|
|
104
113
|
[Vedant K](https://github.com/gamemaker1)
|
|
114
|
+
|
|
115
|
+
[`windowMs`]:
|
|
116
|
+
https://express-rate-limit.mintlify.app/reference/configuration#windowms
|
|
117
|
+
[`limit`]: https://express-rate-limit.mintlify.app/reference/configuration#limit
|
|
118
|
+
[`message`]:
|
|
119
|
+
https://express-rate-limit.mintlify.app/reference/configuration#message
|
|
120
|
+
[`statusCode`]:
|
|
121
|
+
https://express-rate-limit.mintlify.app/reference/configuration#statuscode
|
|
122
|
+
[`handler`]:
|
|
123
|
+
https://express-rate-limit.mintlify.app/reference/configuration#handler
|
|
124
|
+
[`legacyHeaders`]:
|
|
125
|
+
https://express-rate-limit.mintlify.app/reference/configuration#legacyheaders
|
|
126
|
+
[`standardHeaders`]:
|
|
127
|
+
https://express-rate-limit.mintlify.app/reference/configuration#standardheaders
|
|
128
|
+
[`store`]: https://express-rate-limit.mintlify.app/reference/configuration#store
|
|
129
|
+
[`keyGenerator`]:
|
|
130
|
+
https://express-rate-limit.mintlify.app/reference/configuration#keygenerator
|
|
131
|
+
[`requestPropertyName`]:
|
|
132
|
+
https://express-rate-limit.mintlify.app/reference/configuration#requestpropertyname
|
|
133
|
+
[`skip`]: https://express-rate-limit.mintlify.app/reference/configuration#skip
|
|
134
|
+
[`skipSuccessfulRequests`]:
|
|
135
|
+
https://express-rate-limit.mintlify.app/reference/configuration#skipsuccessfulrequests
|
|
136
|
+
[`skipFailedRequests`]:
|
|
137
|
+
https://express-rate-limit.mintlify.app/reference/configuration#skipfailedrequests
|
|
138
|
+
[`requestWasSuccessful`]:
|
|
139
|
+
https://express-rate-limit.mintlify.app/reference/configuration#requestwassuccessful
|
|
140
|
+
[`validate`]:
|
|
141
|
+
https://express-rate-limit.mintlify.app/reference/configuration#validate
|