rate-limiter-flexible 11.0.0 → 11.0.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/README.md +1 -1
- package/lib/RateLimiterMemory.js +2 -0
- package/lib/RateLimiterStoreAbstract.js +3 -0
- package/package.json +20 -20
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Memory limiter also works in the browser.
|
|
|
32
32
|
|
|
33
33
|
**Deno compatible** See [this example](https://gist.github.com/animir/d06ca92931677f330d3f2d4c6c3108e4)
|
|
34
34
|
|
|
35
|
-
The
|
|
35
|
+
The Flexible Fixed Window algorithm starts counting from the moment a request is received, diversifying rate limit reset times across clients. Read more [here](https://github.com/animir/node-rate-limiter-flexible/wiki/Fixed-Window-rate-limiting-algorithm-explained)
|
|
36
36
|
|
|
37
37
|
## Installation
|
|
38
38
|
|
package/lib/RateLimiterMemory.js
CHANGED
|
@@ -35,6 +35,8 @@ class RateLimiterMemory extends RateLimiterAbstract {
|
|
|
35
35
|
if (delay < this.execEvenlyMinDelayMs) {
|
|
36
36
|
delay = res.consumedPoints * this.execEvenlyMinDelayMs;
|
|
37
37
|
}
|
|
38
|
+
// Adjust msBeforeNext to reflect time already waited before resolving
|
|
39
|
+
res.msBeforeNext = Math.max(res.msBeforeNext - delay, 0);
|
|
38
40
|
|
|
39
41
|
setTimeout(resolve, delay, res);
|
|
40
42
|
} else {
|
|
@@ -85,6 +85,9 @@ module.exports = class RateLimiterStoreAbstract extends RateLimiterInsuredAbstra
|
|
|
85
85
|
delay = res.consumedPoints * this.execEvenlyMinDelayMs;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
// Adjust msBeforeNext to reflect time already waited before resolving
|
|
89
|
+
res.msBeforeNext = Math.max(res.msBeforeNext - delay, 0);
|
|
90
|
+
|
|
88
91
|
setTimeout(resolve, delay, res);
|
|
89
92
|
} else {
|
|
90
93
|
resolve(res);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rate-limiter-flexible",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"description": "Node.js atomic and non-atomic counters, rate limiting tools, protection from DoS and brute-force attacks at scale",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -53,32 +53,32 @@
|
|
|
53
53
|
"homepage": "https://github.com/animir/node-rate-limiter-flexible#readme",
|
|
54
54
|
"types": "./types.d.ts",
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
57
|
-
"@prisma/client": "^5.
|
|
58
|
-
"@valkey/valkey-glide": "^1.3.
|
|
59
|
-
"better-sqlite3": "^11.
|
|
60
|
-
"chai": "^4.
|
|
61
|
-
"coveralls": "^3.
|
|
62
|
-
"drizzle-kit": "^0.31.
|
|
63
|
-
"drizzle-orm": "^0.
|
|
56
|
+
"@aws-sdk/client-dynamodb": "^3.1029.0",
|
|
57
|
+
"@prisma/client": "^5.22.0",
|
|
58
|
+
"@valkey/valkey-glide": "^1.3.4",
|
|
59
|
+
"better-sqlite3": "^11.10.0",
|
|
60
|
+
"chai": "^4.5.0",
|
|
61
|
+
"coveralls": "^3.1.1",
|
|
62
|
+
"drizzle-kit": "^0.31.10",
|
|
63
|
+
"drizzle-orm": "^0.45.2",
|
|
64
64
|
"eslint": "^4.19.1",
|
|
65
65
|
"eslint-config-airbnb-base": "^12.1.0",
|
|
66
|
-
"eslint-plugin-import": "^2.
|
|
66
|
+
"eslint-plugin-import": "^2.32.0",
|
|
67
67
|
"eslint-plugin-node": "^6.0.1",
|
|
68
|
-
"eslint-plugin-security": "^1.
|
|
68
|
+
"eslint-plugin-security": "^1.7.1",
|
|
69
69
|
"etcd3": "^1.1.2",
|
|
70
|
-
"ioredis": "^5.
|
|
71
|
-
"iovalkey": "^0.3.
|
|
70
|
+
"ioredis": "^5.10.1",
|
|
71
|
+
"iovalkey": "^0.3.3",
|
|
72
72
|
"istanbul": "^1.1.0-alpha.1",
|
|
73
|
-
"knex": "^3.
|
|
73
|
+
"knex": "^3.2.9",
|
|
74
74
|
"memcached-mock": "^0.1.0",
|
|
75
|
-
"mocha": "^10.2
|
|
75
|
+
"mocha": "^10.8.2",
|
|
76
76
|
"nyc": "^15.1.0",
|
|
77
|
-
"pg": "^8.
|
|
78
|
-
"prisma": "^5.
|
|
79
|
-
"redis": "^4.
|
|
80
|
-
"redis-mock": "^0.
|
|
81
|
-
"sinon": "^17.0.
|
|
77
|
+
"pg": "^8.20.0",
|
|
78
|
+
"prisma": "^5.22.0",
|
|
79
|
+
"redis": "^4.7.1",
|
|
80
|
+
"redis-mock": "^0.56.3",
|
|
81
|
+
"sinon": "^17.0.2",
|
|
82
82
|
"sqlite3": "^5.1.7"
|
|
83
83
|
},
|
|
84
84
|
"browser": {
|