express-rate-limit 7.1.4 → 7.2.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 +17 -2
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +17 -2
- package/package.json +4 -6
- package/readme.md +39 -11
- package/changelog.md +0 -417
package/dist/index.cjs
CHANGED
|
@@ -296,6 +296,20 @@ var validations = {
|
|
|
296
296
|
);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
+
},
|
|
300
|
+
/**
|
|
301
|
+
* Checks to see if the instance was created inside of a request handler, which would prevent it from working correctly.
|
|
302
|
+
*/
|
|
303
|
+
creationStack() {
|
|
304
|
+
const { stack } = new Error(
|
|
305
|
+
"express-rate-limit validation check (set options.validate.creationStack=false to disable)"
|
|
306
|
+
);
|
|
307
|
+
if (stack?.includes("Layer.handle [as handle_request]")) {
|
|
308
|
+
throw new ValidationError(
|
|
309
|
+
"ERR_ERL_CREATED_IN_REQUEST_HANDLER",
|
|
310
|
+
`express-rate-limit instance should be created at app initialization, not when responding to a request.`
|
|
311
|
+
);
|
|
312
|
+
}
|
|
299
313
|
}
|
|
300
314
|
};
|
|
301
315
|
var getValidations = (_enabled) => {
|
|
@@ -616,6 +630,7 @@ var handleAsyncErrors = (fn) => async (request, response, next) => {
|
|
|
616
630
|
var rateLimit = (passedOptions) => {
|
|
617
631
|
const config = parseOptions(passedOptions ?? {});
|
|
618
632
|
const options = getOptionsFromConfig(config);
|
|
633
|
+
config.validations.creationStack();
|
|
619
634
|
if (typeof config.store.init === "function")
|
|
620
635
|
config.store.init(options);
|
|
621
636
|
const middleware = handleAsyncErrors(
|
|
@@ -666,7 +681,7 @@ var rateLimit = (passedOptions) => {
|
|
|
666
681
|
};
|
|
667
682
|
if (config.skipFailedRequests) {
|
|
668
683
|
response.on("finish", async () => {
|
|
669
|
-
if (!config.requestWasSuccessful(request, response))
|
|
684
|
+
if (!await config.requestWasSuccessful(request, response))
|
|
670
685
|
await decrementKey();
|
|
671
686
|
});
|
|
672
687
|
response.on("close", async () => {
|
|
@@ -679,7 +694,7 @@ var rateLimit = (passedOptions) => {
|
|
|
679
694
|
}
|
|
680
695
|
if (config.skipSuccessfulRequests) {
|
|
681
696
|
response.on("finish", async () => {
|
|
682
|
-
if (config.requestWasSuccessful(request, response))
|
|
697
|
+
if (await config.requestWasSuccessful(request, response))
|
|
683
698
|
await decrementKey();
|
|
684
699
|
});
|
|
685
700
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -97,6 +97,10 @@ declare const validations: {
|
|
|
97
97
|
* If any unrecognized values are found, an error is logged that includes the list of supported vaidations.
|
|
98
98
|
*/
|
|
99
99
|
validationsConfig(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Checks to see if the instance was created inside of a request handler, which would prevent it from working correctly.
|
|
102
|
+
*/
|
|
103
|
+
creationStack(): void;
|
|
100
104
|
};
|
|
101
105
|
export type Validations = typeof validations;
|
|
102
106
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -97,6 +97,10 @@ declare const validations: {
|
|
|
97
97
|
* If any unrecognized values are found, an error is logged that includes the list of supported vaidations.
|
|
98
98
|
*/
|
|
99
99
|
validationsConfig(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Checks to see if the instance was created inside of a request handler, which would prevent it from working correctly.
|
|
102
|
+
*/
|
|
103
|
+
creationStack(): void;
|
|
100
104
|
};
|
|
101
105
|
export type Validations = typeof validations;
|
|
102
106
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -97,6 +97,10 @@ declare const validations: {
|
|
|
97
97
|
* If any unrecognized values are found, an error is logged that includes the list of supported vaidations.
|
|
98
98
|
*/
|
|
99
99
|
validationsConfig(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Checks to see if the instance was created inside of a request handler, which would prevent it from working correctly.
|
|
102
|
+
*/
|
|
103
|
+
creationStack(): void;
|
|
100
104
|
};
|
|
101
105
|
export type Validations = typeof validations;
|
|
102
106
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -268,6 +268,20 @@ var validations = {
|
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
+
},
|
|
272
|
+
/**
|
|
273
|
+
* Checks to see if the instance was created inside of a request handler, which would prevent it from working correctly.
|
|
274
|
+
*/
|
|
275
|
+
creationStack() {
|
|
276
|
+
const { stack } = new Error(
|
|
277
|
+
"express-rate-limit validation check (set options.validate.creationStack=false to disable)"
|
|
278
|
+
);
|
|
279
|
+
if (stack?.includes("Layer.handle [as handle_request]")) {
|
|
280
|
+
throw new ValidationError(
|
|
281
|
+
"ERR_ERL_CREATED_IN_REQUEST_HANDLER",
|
|
282
|
+
`express-rate-limit instance should be created at app initialization, not when responding to a request.`
|
|
283
|
+
);
|
|
284
|
+
}
|
|
271
285
|
}
|
|
272
286
|
};
|
|
273
287
|
var getValidations = (_enabled) => {
|
|
@@ -588,6 +602,7 @@ var handleAsyncErrors = (fn) => async (request, response, next) => {
|
|
|
588
602
|
var rateLimit = (passedOptions) => {
|
|
589
603
|
const config = parseOptions(passedOptions ?? {});
|
|
590
604
|
const options = getOptionsFromConfig(config);
|
|
605
|
+
config.validations.creationStack();
|
|
591
606
|
if (typeof config.store.init === "function")
|
|
592
607
|
config.store.init(options);
|
|
593
608
|
const middleware = handleAsyncErrors(
|
|
@@ -638,7 +653,7 @@ var rateLimit = (passedOptions) => {
|
|
|
638
653
|
};
|
|
639
654
|
if (config.skipFailedRequests) {
|
|
640
655
|
response.on("finish", async () => {
|
|
641
|
-
if (!config.requestWasSuccessful(request, response))
|
|
656
|
+
if (!await config.requestWasSuccessful(request, response))
|
|
642
657
|
await decrementKey();
|
|
643
658
|
});
|
|
644
659
|
response.on("close", async () => {
|
|
@@ -651,7 +666,7 @@ var rateLimit = (passedOptions) => {
|
|
|
651
666
|
}
|
|
652
667
|
if (config.skipSuccessfulRequests) {
|
|
653
668
|
response.on("finish", async () => {
|
|
654
|
-
if (config.requestWasSuccessful(request, response))
|
|
669
|
+
if (await config.requestWasSuccessful(request, response))
|
|
655
670
|
await decrementKey();
|
|
656
671
|
});
|
|
657
672
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-rate-limit",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.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",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git+https://github.com/express-rate-limit/express-rate-limit.git"
|
|
14
14
|
},
|
|
15
|
+
"funding": "https://github.com/sponsors/express-rate-limit",
|
|
15
16
|
"keywords": [
|
|
16
17
|
"express-rate-limit",
|
|
17
18
|
"express",
|
|
@@ -48,11 +49,7 @@
|
|
|
48
49
|
"types": "./dist/index.d.ts",
|
|
49
50
|
"files": [
|
|
50
51
|
"dist/",
|
|
51
|
-
"tsconfig.json"
|
|
52
|
-
"package.json",
|
|
53
|
-
"readme.md",
|
|
54
|
-
"license.md",
|
|
55
|
-
"changelog.md"
|
|
52
|
+
"tsconfig.json"
|
|
56
53
|
],
|
|
57
54
|
"engines": {
|
|
58
55
|
"node": ">= 16"
|
|
@@ -94,6 +91,7 @@
|
|
|
94
91
|
"husky": "8.0.3",
|
|
95
92
|
"jest": "29.7.0",
|
|
96
93
|
"lint-staged": "15.0.2",
|
|
94
|
+
"mintlify": "4.0.63",
|
|
97
95
|
"npm-run-all": "4.1.5",
|
|
98
96
|
"ratelimit-header-parser": "0.1.0",
|
|
99
97
|
"supertest": "6.3.3",
|
package/readme.md
CHANGED
|
@@ -9,16 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
Sponsored by [Zuplo](https://zuplo.link/express-rate-limit) a fully-managed API
|
|
15
|
-
Gateway for developers. Add
|
|
16
|
-
[dynamic rate-limiting](https://zuplo.link/dynamic-rate-limiting),
|
|
17
|
-
authentication and more to any API in minutes. Learn more at
|
|
18
|
-
[zuplo.com](https://zuplo.link/express-rate-limit)
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
12
|
Basic rate-limiting middleware for [Express](http://expressjs.com/). Use to
|
|
23
13
|
limit repeated requests to public APIs and/or endpoints such as password reset.
|
|
24
14
|
Plays nice with
|
|
@@ -38,13 +28,49 @@ const limiter = rateLimit({
|
|
|
38
28
|
limit: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes).
|
|
39
29
|
standardHeaders: 'draft-7', // draft-6: `RateLimit-*` headers; draft-7: combined `RateLimit` header
|
|
40
30
|
legacyHeaders: false, // Disable the `X-RateLimit-*` headers.
|
|
41
|
-
// store: ... , //
|
|
31
|
+
// store: ... , // Redis, Memcached, etc. See below.
|
|
42
32
|
})
|
|
43
33
|
|
|
44
34
|
// Apply the rate limiting middleware to all requests.
|
|
45
35
|
app.use(limiter)
|
|
46
36
|
```
|
|
47
37
|
|
|
38
|
+
### Data Stores
|
|
39
|
+
|
|
40
|
+
The rate limiter comes with a built-in memory store, and supports a variety of
|
|
41
|
+
[external data stores](https://express-rate-limit.mintlify.app/reference/stores).
|
|
42
|
+
|
|
43
|
+
### Configuration
|
|
44
|
+
|
|
45
|
+
All function options may be async. Click the name for additional info and
|
|
46
|
+
default values.
|
|
47
|
+
|
|
48
|
+
| Option | Type | Remarks |
|
|
49
|
+
| ------------------------------------------------------------------------------------------------------------------ | -------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
50
|
+
| [`windowMs`](https://express-rate-limit.mintlify.app/reference/configuration#windowms) | `number` | How long to remember requests for, in milliseconds. |
|
|
51
|
+
| [`limit`](https://express-rate-limit.mintlify.app/reference/configuration#limit) | `number` \| `function` | How many requests to allow. |
|
|
52
|
+
| [`message`](https://express-rate-limit.mintlify.app/reference/configuration#message) | `string` \| `json` \| `function` | Response to return after limit is reached. |
|
|
53
|
+
| [`statusCode`](https://express-rate-limit.mintlify.app/reference/configuration#statuscode) | `number` | HTTP status code after limit is reached (default is 429). |
|
|
54
|
+
| [`legacyHeaders`](https://express-rate-limit.mintlify.app/reference/configuration#legacyheaders) | `boolean` | Enable the `X-Rate-Limit` header. |
|
|
55
|
+
| [`standardHeaders`](https://express-rate-limit.mintlify.app/reference/configuration#standardheaders) | `'draft-6'` \| `'draft-7'` | Enable the `Ratelimit` header. |
|
|
56
|
+
| [`requestPropertyName`](https://express-rate-limit.mintlify.app/reference/configuration#requestpropertyname) | `string` | Add rate limit info to the `req` object. |
|
|
57
|
+
| [`skipFailedRequests`](https://express-rate-limit.mintlify.app/reference/configuration#skipfailedrequests) | `boolean` | Uncount 4xx/5xx responses. |
|
|
58
|
+
| [`skipSuccessfulRequests`](https://express-rate-limit.mintlify.app/reference/configuration#skipsuccessfulrequests) | `boolean` | Uncount 1xx/2xx/3xx responses. |
|
|
59
|
+
| [`keyGenerator`](https://express-rate-limit.mintlify.app/reference/configuration#keygenerator) | `function` | Identify users (defaults to IP address). |
|
|
60
|
+
| [`handler`](https://express-rate-limit.mintlify.app/reference/configuration#handler) | `function` | Function to run after limit is reached (overrides `message` and `statusCode` settings, if set). |
|
|
61
|
+
| [`skip`](https://express-rate-limit.mintlify.app/reference/configuration#skip) | `function` | Return `true` to bypass the limiter for the given request. |
|
|
62
|
+
| [`requestWasSuccessful`](https://express-rate-limit.mintlify.app/reference/configuration#requestwassuccessful) | `function` | Used by `skipFailedRequests` and `skipSuccessfulRequests`. |
|
|
63
|
+
| [`validate`](https://express-rate-limit.mintlify.app/reference/configuration#validate) | `boolean` \| `object` | Enable or disable built-in validation checks. |
|
|
64
|
+
| [`store`](https://express-rate-limit.mintlify.app/reference/configuration#store) | `Store` | Use a custom store to share hit counts across multiple nodes. |
|
|
65
|
+
|
|
66
|
+
## Thank You
|
|
67
|
+
|
|
68
|
+
Sponsored by [Zuplo](https://zuplo.link/express-rate-limit) a fully-managed API
|
|
69
|
+
Gateway for developers. Add
|
|
70
|
+
[dynamic rate-limiting](https://zuplo.link/dynamic-rate-limiting),
|
|
71
|
+
authentication and more to any API in minutes. Learn more at
|
|
72
|
+
[zuplo.com](https://zuplo.link/express-rate-limit)
|
|
73
|
+
|
|
48
74
|
---
|
|
49
75
|
|
|
50
76
|
Thanks to Mintlify for hosting the documentation at
|
|
@@ -58,6 +84,8 @@ Thanks to Mintlify for hosting the documentation at
|
|
|
58
84
|
|
|
59
85
|
---
|
|
60
86
|
|
|
87
|
+
Finally, thank you to everyone who's contributed to this project in any way! 🫶
|
|
88
|
+
|
|
61
89
|
## Issues and Contributing
|
|
62
90
|
|
|
63
91
|
If you encounter a bug or want to see something added/changed, please go ahead
|
package/changelog.md
DELETED
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to
|
|
7
|
-
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
|
-
|
|
9
|
-
## [7.1.4](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.1.4)
|
|
10
|
-
|
|
11
|
-
### Fixed
|
|
12
|
-
|
|
13
|
-
- Ensure header values are strings rather than numbers, for compatibility with
|
|
14
|
-
[Bun](https://bun.sh/)
|
|
15
|
-
|
|
16
|
-
## [7.1.3](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.1.3)
|
|
17
|
-
|
|
18
|
-
### Changed
|
|
19
|
-
|
|
20
|
-
- Loosened peer dependencies to explicitly allow the Express 5 beta. (See
|
|
21
|
-
[#415](https://github.com/express-rate-limit/express-rate-limit/issues/415))
|
|
22
|
-
|
|
23
|
-
## [7.1.2](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.1.2)
|
|
24
|
-
|
|
25
|
-
### Changed
|
|
26
|
-
|
|
27
|
-
- Re-organized documentation from readme into docs/ folder and added
|
|
28
|
-
documentation website.
|
|
29
|
-
|
|
30
|
-
## [v7.1.1](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.1.1)
|
|
31
|
-
|
|
32
|
-
### Added
|
|
33
|
-
|
|
34
|
-
- Enabled provenance statement generation, see
|
|
35
|
-
https://github.com/express-rate-limit/express-rate-limit#406.
|
|
36
|
-
|
|
37
|
-
## [7.1.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.1.0)
|
|
38
|
-
|
|
39
|
-
### Changed
|
|
40
|
-
|
|
41
|
-
- The `getKey` method is now always defined. If the store does not have the
|
|
42
|
-
required `get` method, `getKey` will throw an error explaining this.
|
|
43
|
-
|
|
44
|
-
## [7.0.2](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.0.2)
|
|
45
|
-
|
|
46
|
-
### Added
|
|
47
|
-
|
|
48
|
-
- Added `cluster-memory-store` to the readme and made a couple of other minor
|
|
49
|
-
clarifications.
|
|
50
|
-
|
|
51
|
-
## [7.0.1](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.0.1)
|
|
52
|
-
|
|
53
|
-
### Added
|
|
54
|
-
|
|
55
|
-
- Added `rate-limit-postgresql` to the `stores` list in the readme.
|
|
56
|
-
|
|
57
|
-
## [7.0.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.0.0)
|
|
58
|
-
|
|
59
|
-
### Breaking
|
|
60
|
-
|
|
61
|
-
- Changed behavior when `max` is set to 0:
|
|
62
|
-
- Previously, `max: 0` was treated as a 'disable' flag and would allow all
|
|
63
|
-
requests through.
|
|
64
|
-
- Starting with v7, all requests will be blocked when max is set to 0.
|
|
65
|
-
- To replicate the old behavior, use the
|
|
66
|
-
[skip](https://github.com/express-rate-limit/express-rate-limit#skip)
|
|
67
|
-
function instead.
|
|
68
|
-
- Renamed `req.rateLimit.current` to `req.rateLimit.used`.
|
|
69
|
-
- `current` is now a hidden getter that will return the `used` value, but it
|
|
70
|
-
will not appear when iterating over the keys or calling `JSON.stringify()`.
|
|
71
|
-
- Changed the minimum required Node version from v14 to v16.
|
|
72
|
-
- `express-rate-limit` now targets `es2022` in TypeScript/ESBuild.
|
|
73
|
-
- Bumped TypeScript from v4 to v5 and `dts-bundle-generator` from v7 to v8.
|
|
74
|
-
|
|
75
|
-
### Deprecated
|
|
76
|
-
|
|
77
|
-
- Removed the `draft_polli_ratelimit_headers` option (it was deprecated in v6).
|
|
78
|
-
- Use `standardHeaders: 'draft-6'` instead.
|
|
79
|
-
- Removed the `onLimitReached` option (it was deprecated in v6).
|
|
80
|
-
- [This](<(https://github.com/express-rate-limit/express-rate-limit/wiki/Error-Codes#wrn_erl_deprecated_on_limit_reached)>)
|
|
81
|
-
is an example of how to replicate it's behavior with a custom `handler`
|
|
82
|
-
option.
|
|
83
|
-
|
|
84
|
-
### Changed
|
|
85
|
-
|
|
86
|
-
- The `MemoryStore` now uses precise, per-user reset times rather than a global
|
|
87
|
-
window that resets all users at once.
|
|
88
|
-
- The `limit` configuration option is now prefered to `max`.
|
|
89
|
-
- It still shows the same behavior, and `max` is still supported. The change
|
|
90
|
-
was made to better align with terminology used in the IETF standard drafts.
|
|
91
|
-
|
|
92
|
-
### Added
|
|
93
|
-
|
|
94
|
-
- The `validate` config option can now be an object with keys to enable or
|
|
95
|
-
disable specific validation checks. For more information, see
|
|
96
|
-
[this](https://github.com/express-rate-limit/express-rate-limit#validate).
|
|
97
|
-
|
|
98
|
-
## [6.11.2](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.11.2)
|
|
99
|
-
|
|
100
|
-
### Fixed
|
|
101
|
-
|
|
102
|
-
- Restored `IncrementResponse ` TypeScript type (See
|
|
103
|
-
[#397](https://github.com/express-rate-limit/express-rate-limit/pull/397))
|
|
104
|
-
|
|
105
|
-
## [6.11.1](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.11.1)
|
|
106
|
-
|
|
107
|
-
### Fixed
|
|
108
|
-
|
|
109
|
-
- Check for prefixed keys when validating that the stores have single counted
|
|
110
|
-
keys (See
|
|
111
|
-
[#395](https://github.com/express-rate-limit/express-rate-limit/issues/395)).
|
|
112
|
-
|
|
113
|
-
## [6.11.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.11.0)
|
|
114
|
-
|
|
115
|
-
### Added
|
|
116
|
-
|
|
117
|
-
- Support for retrieving the current hit count and reset time for a given key
|
|
118
|
-
from a store (See
|
|
119
|
-
[#390](https://github.com/express-rate-limit/express-rate-limit/issues/389)).
|
|
120
|
-
|
|
121
|
-
## [6.10.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.10.0)
|
|
122
|
-
|
|
123
|
-
### Added
|
|
124
|
-
|
|
125
|
-
- Support for combined `RateLimit` header from the
|
|
126
|
-
[RateLimit header fields for HTTP standardization draft](https://github.com/ietf-wg-httpapi/ratelimit-headers)
|
|
127
|
-
adopted by the IETF. Enable by setting `standardHeaders: 'draft-7'`.
|
|
128
|
-
- New `standardHeaders: 'draft-6'` option, treated equivalent to
|
|
129
|
-
`standardHeaders: true` from previous releases. Note that `true` and `false`
|
|
130
|
-
are still supported.
|
|
131
|
-
- New `RateLimit-Policy` header added when `standardHeaders` is set to
|
|
132
|
-
`'draft-6'`, `'draft-7'`, or `true`.
|
|
133
|
-
- Warning when using deprecated `draft_polli_ratelimit_headers` option.
|
|
134
|
-
- Warning when using deprecated `onLimitReached` option.
|
|
135
|
-
- Warning when `totalHits` value returned from Store is invalid.
|
|
136
|
-
|
|
137
|
-
## [6.9.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.9.0)
|
|
138
|
-
|
|
139
|
-
### Added
|
|
140
|
-
|
|
141
|
-
- New validaion check for double-counted requests.
|
|
142
|
-
- Added help link to each validation error, directing users to the appropriate
|
|
143
|
-
wiki page for more info.
|
|
144
|
-
|
|
145
|
-
### Changed
|
|
146
|
-
|
|
147
|
-
- Miscellaneous documenation improvements.
|
|
148
|
-
|
|
149
|
-
## [6.8.1](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.8.0) & [6.7.2](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.8.0)
|
|
150
|
-
|
|
151
|
-
### Changed
|
|
152
|
-
|
|
153
|
-
- Revert 6.7.1 change that bumped typescript from 5.x to 4.x and
|
|
154
|
-
dts-bundle-generator from 8.x to 7.x (See
|
|
155
|
-
[#360](https://github.com/express-rate-limit/express-rate-limit/issues/360)).
|
|
156
|
-
|
|
157
|
-
## [6.8.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.8.0)
|
|
158
|
-
|
|
159
|
-
### Added
|
|
160
|
-
|
|
161
|
-
- Added a set of validation checks that will log an error if failed. See
|
|
162
|
-
https://github.com/express-rate-limit/express-rate-limit/wiki/Error-Codes for
|
|
163
|
-
a list of potential errors. Can be disabled by setting `validate: false` in
|
|
164
|
-
the configuration. Automatically disables after the first request. (See
|
|
165
|
-
[#358](https://github.com/express-rate-limit/express-rate-limit/issues/358)).
|
|
166
|
-
|
|
167
|
-
## [6.7.1](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.7.1)
|
|
168
|
-
|
|
169
|
-
### Fixed
|
|
170
|
-
|
|
171
|
-
- Fixed compatibility with TypeScript's TypeScript new `node16` module
|
|
172
|
-
resolution strategy (See
|
|
173
|
-
[#355](https://github.com/express-rate-limit/express-rate-limit/issues/355)).
|
|
174
|
-
|
|
175
|
-
### Changed
|
|
176
|
-
|
|
177
|
-
- Bumped development dependencies
|
|
178
|
-
- This initially include bumping typescript from 4.x to 5.x and
|
|
179
|
-
dts-bundle-generator from 7.x to 8.x
|
|
180
|
-
- Added `node` 20 to list of versions the CI jobs run on.
|
|
181
|
-
|
|
182
|
-
No functional changes.
|
|
183
|
-
|
|
184
|
-
## [6.7.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.7.0)
|
|
185
|
-
|
|
186
|
-
### Changed
|
|
187
|
-
|
|
188
|
-
- Updated links to point to the new `express-rate-limit` organization on GitHub.
|
|
189
|
-
- Added advertisement to `readme.md` for project sponsor
|
|
190
|
-
[Zuplo](https://zuplo.link/express-rate-limit).
|
|
191
|
-
- Updated to `typescript` version 5 and bumped other dependencies.
|
|
192
|
-
- Dropped `node` 12, and added `node` 19 to the list of versions the CI jobs run
|
|
193
|
-
on.
|
|
194
|
-
|
|
195
|
-
No functional changes.
|
|
196
|
-
|
|
197
|
-
## [6.6.0](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.6.0)
|
|
198
|
-
|
|
199
|
-
### Added
|
|
200
|
-
|
|
201
|
-
- Added `shutdown` method to the Store interface and the MemoryStore.
|
|
202
|
-
|
|
203
|
-
## [6.5.2](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.5.2)
|
|
204
|
-
|
|
205
|
-
### Fixed
|
|
206
|
-
|
|
207
|
-
- Fixed an issue with missing types in ESM monorepos.
|
|
208
|
-
|
|
209
|
-
## [6.5.1](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.5.1)
|
|
210
|
-
|
|
211
|
-
### Added
|
|
212
|
-
|
|
213
|
-
- The message option can now be a (sync/asynx) function that returns a value
|
|
214
|
-
(#311)
|
|
215
|
-
|
|
216
|
-
### Changed
|
|
217
|
-
|
|
218
|
-
- Updated all dependencies
|
|
219
|
-
|
|
220
|
-
Note: 6.5.0 was not released due to CI automation issues.
|
|
221
|
-
|
|
222
|
-
## [6.4.0](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.3.0)
|
|
223
|
-
|
|
224
|
-
### Added
|
|
225
|
-
|
|
226
|
-
- Adds Express 5 (`5.0.0-beta.1`) as a supported peer dependency (#304)
|
|
227
|
-
|
|
228
|
-
### Changed
|
|
229
|
-
|
|
230
|
-
- Tests are now run on Node 12, 14, 16 and 18 on CI (#305)
|
|
231
|
-
- Updated all development dependencies (#306)
|
|
232
|
-
|
|
233
|
-
## [6.3.0](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.3.0)
|
|
234
|
-
|
|
235
|
-
### Changed
|
|
236
|
-
|
|
237
|
-
- Changes the build target to es2019 so that ESBuild outputs code that can run
|
|
238
|
-
with Node 12.
|
|
239
|
-
- Changes the minimum required Node version to 12.9.0.
|
|
240
|
-
|
|
241
|
-
## [6.2.1](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.2.1)
|
|
242
|
-
|
|
243
|
-
### Fixed
|
|
244
|
-
|
|
245
|
-
- Use the default value for an option when `undefined` is passed to the rate
|
|
246
|
-
limiter.
|
|
247
|
-
|
|
248
|
-
## [6.2.0](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.2.0)
|
|
249
|
-
|
|
250
|
-
### Added
|
|
251
|
-
|
|
252
|
-
- Export the `MemoryStore`, so it can now be imported as a named import
|
|
253
|
-
(`import { MemoryStore } from 'express-rate-limit'`).
|
|
254
|
-
|
|
255
|
-
### Fixed
|
|
256
|
-
|
|
257
|
-
- Deprecate the `onLimitReached` option (this was supposed to be deprecated in
|
|
258
|
-
v6.0.0 itself); developers should use a custom handler function that checks if
|
|
259
|
-
the rate limit has been exceeded instead.
|
|
260
|
-
|
|
261
|
-
## [6.1.0](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.1.0)
|
|
262
|
-
|
|
263
|
-
### Added
|
|
264
|
-
|
|
265
|
-
- Added a named export `rateLimit` in case the default import does not work.
|
|
266
|
-
|
|
267
|
-
### Fixed
|
|
268
|
-
|
|
269
|
-
- Added a named export `default`, so Typescript CommonJS developers can
|
|
270
|
-
default-import the library (`import rateLimit from 'express-rate-limit'`).
|
|
271
|
-
|
|
272
|
-
## [6.0.5](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.0.5)
|
|
273
|
-
|
|
274
|
-
### Fixed
|
|
275
|
-
|
|
276
|
-
- Use named imports for ExpressJS types so users do not need to enable the
|
|
277
|
-
`esModuleInterop` flag in their Typescript compiler configuration.
|
|
278
|
-
|
|
279
|
-
## [6.0.4](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.0.4)
|
|
280
|
-
|
|
281
|
-
### Fixed
|
|
282
|
-
|
|
283
|
-
- Upload the built package as a `.tgz` to GitHub releases.
|
|
284
|
-
|
|
285
|
-
### Changed
|
|
286
|
-
|
|
287
|
-
- Add ` main` and `module` fields to `package.json`. This helps tools such as
|
|
288
|
-
ESLint that do not yet support the `exports` field.
|
|
289
|
-
- Bumped the minimum node.js version in `package-lock.json` to match
|
|
290
|
-
`package.json`
|
|
291
|
-
|
|
292
|
-
## [6.0.3](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.0.3)
|
|
293
|
-
|
|
294
|
-
### Changed
|
|
295
|
-
|
|
296
|
-
- Bumped minimum Node version from 12.9 to 14.5 in `package.json` because the
|
|
297
|
-
transpiled output uses the nullish coalescing operator (`??`), which
|
|
298
|
-
[isn't supported in node.js prior to 14.x](https://node.green/#ES2020-features--nullish-coalescing-operator-----).
|
|
299
|
-
|
|
300
|
-
## [6.0.2](https://github.com/nfriedly/express-rate-limit/releases/v6.0.2)
|
|
301
|
-
|
|
302
|
-
### Fixed
|
|
303
|
-
|
|
304
|
-
- Ensure CommonJS projects can import the module.
|
|
305
|
-
|
|
306
|
-
### Added
|
|
307
|
-
|
|
308
|
-
- Add additional tests that test:
|
|
309
|
-
- importing the library in `js-cjs`, `js-esm`, `ts-cjs`, `ts-esm`
|
|
310
|
-
environments.
|
|
311
|
-
- usage of the library with external stores (`redis`, `mongo`, `memcached`,
|
|
312
|
-
`precise`).
|
|
313
|
-
|
|
314
|
-
### Changed
|
|
315
|
-
|
|
316
|
-
- Use [`esbuild`](https://esbuild.github.io/) to generate ESM and CJS output.
|
|
317
|
-
This reduces the size of the built package from 138 kb to 13kb and build time
|
|
318
|
-
to 4 ms! :rocket:
|
|
319
|
-
- Use [`dts-bundle-generator`](https://github.com/timocov/dts-bundle-generator)
|
|
320
|
-
to generate a single Typescript declaration file.
|
|
321
|
-
|
|
322
|
-
## [6.0.1](https://github.com/nfriedly/express-rate-limit/releases/v6.0.1)
|
|
323
|
-
|
|
324
|
-
### Fixed
|
|
325
|
-
|
|
326
|
-
- Ensure CommonJS projects can import the module.
|
|
327
|
-
|
|
328
|
-
## [6.0.0](https://github.com/nfriedly/express-rate-limit/releases/v6.0.0)
|
|
329
|
-
|
|
330
|
-
### Added
|
|
331
|
-
|
|
332
|
-
- `express` 4.x as a peer dependency.
|
|
333
|
-
- Better Typescript support (the library was rewritten in Typescript).
|
|
334
|
-
- Export the package as both ESM and CJS.
|
|
335
|
-
- Publish the built package (`.tgz` file) on GitHub releases as well as the npm
|
|
336
|
-
registry.
|
|
337
|
-
- Issue and PR templates.
|
|
338
|
-
- A contributing guide.
|
|
339
|
-
|
|
340
|
-
### Changed
|
|
341
|
-
|
|
342
|
-
- Rename the `draft_polli_ratelimit_headers` option to `standardHeaders`.
|
|
343
|
-
- Rename the `headers` option to `legacyHeaders`.
|
|
344
|
-
- `Retry-After` header is now sent if either `legacyHeaders` or
|
|
345
|
-
`standardHeaders` is set.
|
|
346
|
-
- Allow `keyGenerator` to be an async function/return a promise.
|
|
347
|
-
- Change the way custom stores are defined.
|
|
348
|
-
- Add the `init` method for stores to set themselves up using options passed
|
|
349
|
-
to the middleware.
|
|
350
|
-
- Rename the `incr` method to `increment`.
|
|
351
|
-
- Allow the `increment`, `decrement`, `resetKey` and `resetAll` methods to
|
|
352
|
-
return a promise.
|
|
353
|
-
- Old stores will automatically be promisified and used.
|
|
354
|
-
- The package can now only be used with NodeJS version 12.9.0 or greater.
|
|
355
|
-
- The `onLimitReached` configuration option is now deprecated. Replace it with a
|
|
356
|
-
custom `handler` that checks the number of hits.
|
|
357
|
-
|
|
358
|
-
### Removed
|
|
359
|
-
|
|
360
|
-
- Remove the deprecated `limiter.resetIp` method (use the `limiter.resetKey`
|
|
361
|
-
method instead).
|
|
362
|
-
- Remove the deprecated options `delayMs`, `delayAfter` (the delay functionality
|
|
363
|
-
was moved to the
|
|
364
|
-
[`express-slow-down`](https://github.com/nfriedly/express-slow-down) package)
|
|
365
|
-
and `global` (use a key generator that returns a constant value).
|
|
366
|
-
|
|
367
|
-
## [5.x](https://github.com/nfriedly/express-rate-limit/releases/tag/v5.5.1)
|
|
368
|
-
|
|
369
|
-
### Added
|
|
370
|
-
|
|
371
|
-
- The middleware ~throws~ logs an error if `request.ip` is undefined.
|
|
372
|
-
|
|
373
|
-
### Removed
|
|
374
|
-
|
|
375
|
-
- Removes typescript typings. (See
|
|
376
|
-
[#138](https://github.com/nfriedly/express-rate-limit/issues/138))
|
|
377
|
-
|
|
378
|
-
## [4.x](https://github.com/nfriedly/express-rate-limit/releases/tag/v4.0.4)
|
|
379
|
-
|
|
380
|
-
### Changed
|
|
381
|
-
|
|
382
|
-
- The library no longer modifies the passed-in options object, it instead makes
|
|
383
|
-
a clone of it.
|
|
384
|
-
|
|
385
|
-
## [3.x](https://github.com/nfriedly/express-rate-limit/releases/tag/v3.5.2)
|
|
386
|
-
|
|
387
|
-
### Added
|
|
388
|
-
|
|
389
|
-
- Simplifies the default `handler` function so that it no longer changes the
|
|
390
|
-
response format. The default handler also uses
|
|
391
|
-
[response.send](https://expressjs.com/en/4x/api.html#response.send).
|
|
392
|
-
|
|
393
|
-
### Changes
|
|
394
|
-
|
|
395
|
-
- `onLimitReached` now only triggers once for a client and window. However, the
|
|
396
|
-
`handle` method is called for every blocked request.
|
|
397
|
-
|
|
398
|
-
### Removed
|
|
399
|
-
|
|
400
|
-
- The `delayAfter` and `delayMs` options; they were moved to the
|
|
401
|
-
[express-slow-down](https://npmjs.org/package/express-slow-down) package.
|
|
402
|
-
|
|
403
|
-
## [2.x](https://github.com/nfriedly/express-rate-limit/releases/tag/v2.14.2)
|
|
404
|
-
|
|
405
|
-
### Added
|
|
406
|
-
|
|
407
|
-
- Support external stores (from version 2.3.0) onwards.
|
|
408
|
-
- A `limiter.resetKey()` method to reset the hit counter for a particular client
|
|
409
|
-
|
|
410
|
-
### Changes
|
|
411
|
-
|
|
412
|
-
- The rate limiter now uses a less precise but less resource intensive method of
|
|
413
|
-
tracking hits from a client.
|
|
414
|
-
|
|
415
|
-
### Removed
|
|
416
|
-
|
|
417
|
-
- The `global` option.
|