rate-limiter-flexible 7.3.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.
|
@@ -9,12 +9,14 @@ class RateLimiterDrizzleError extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function getDrizzleOperators() {
|
|
12
|
+
async function getDrizzleOperators() {
|
|
13
13
|
if (drizzleOperators) return drizzleOperators;
|
|
14
14
|
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// Use dynamic import to prevent static analysis tools from detecting the import
|
|
17
|
+
const drizzleOrm = await import('drizzle-orm');
|
|
18
|
+
const { and, or, gt, lt, eq, isNull, sql } = drizzleOrm.default || drizzleOrm;
|
|
19
|
+
drizzleOperators = { and, or, gt, lt, eq, isNull, sql };
|
|
18
20
|
return drizzleOperators;
|
|
19
21
|
} catch (error) {
|
|
20
22
|
throw new RateLimiterDrizzleError(
|
|
@@ -66,7 +68,7 @@ class RateLimiterDrizzle extends RateLimiterStoreAbstract {
|
|
|
66
68
|
return Promise.reject(new RateLimiterDrizzleError('Drizzle client is not established'))
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
const { eq
|
|
71
|
+
const { eq, sql } = await getDrizzleOperators();
|
|
70
72
|
const now = new Date();
|
|
71
73
|
const newExpire = msDuration > 0 ? new Date(now.getTime() + msDuration) : null;
|
|
72
74
|
|
|
@@ -112,7 +114,7 @@ class RateLimiterDrizzle extends RateLimiterStoreAbstract {
|
|
|
112
114
|
return Promise.reject(new RateLimiterDrizzleError('Drizzle client is not established'))
|
|
113
115
|
}
|
|
114
116
|
|
|
115
|
-
const { and, or, gt, eq, isNull } = getDrizzleOperators();
|
|
117
|
+
const { and, or, gt, eq, isNull } = await getDrizzleOperators();
|
|
116
118
|
|
|
117
119
|
const [response] = await this.drizzleClient
|
|
118
120
|
.select()
|
|
@@ -134,7 +136,7 @@ class RateLimiterDrizzle extends RateLimiterStoreAbstract {
|
|
|
134
136
|
return Promise.reject(new RateLimiterDrizzleError('Drizzle client is not established'))
|
|
135
137
|
}
|
|
136
138
|
|
|
137
|
-
const { eq } = getDrizzleOperators();
|
|
139
|
+
const { eq } = await getDrizzleOperators();
|
|
138
140
|
|
|
139
141
|
const [result] = await this.drizzleClient
|
|
140
142
|
.delete(this.schema)
|
|
@@ -149,10 +151,9 @@ class RateLimiterDrizzle extends RateLimiterStoreAbstract {
|
|
|
149
151
|
clearTimeout(this._clearExpiredTimeoutId);
|
|
150
152
|
}
|
|
151
153
|
|
|
152
|
-
const { lt } = getDrizzleOperators();
|
|
153
|
-
|
|
154
154
|
this._clearExpiredTimeoutId = setTimeout(async () => {
|
|
155
155
|
try {
|
|
156
|
+
const { lt } = await getDrizzleOperators();
|
|
156
157
|
await this.drizzleClient
|
|
157
158
|
.delete(this.schema)
|
|
158
159
|
.where(lt(this.schema.expire, new Date(Date.now() - EXPIRED_THRESHOLD_MS)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rate-limiter-flexible",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "Node.js rate limiter by key and protection from DDoS and Brute-Force attacks in process Memory, Redis, MongoDb, Memcached, MySQL, PostgreSQL, Cluster or PM",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"test:valkey-cluster": "VALKEY_CLUSTER_PORT=7001 mocha test/RateLimiterValkeyGlide.test.js -- -g 'RateLimiterValkeyGlide with cluster client'",
|
|
12
12
|
"prisma:postgres": "prisma generate --schema=./test/RateLimiterPrisma/Postgres/schema.prisma && prisma db push --schema=./test/RateLimiterPrisma/Postgres/schema.prisma",
|
|
13
13
|
"drizzle:postgres": "cd ./test/RateLimiterDrizzle/Postgres && drizzle-kit push",
|
|
14
|
-
"test": "npm run prisma:postgres && npm run drizzle:postgres && nyc --reporter=html --reporter=text mocha",
|
|
14
|
+
"test": "npm run prisma:postgres && npm run drizzle:postgres && nyc --reporter=html --reporter=text mocha \"test/**/*.test.js\"",
|
|
15
15
|
"debug-test": "mocha --inspect-brk lib/**/**.test.js",
|
|
16
16
|
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
|
17
17
|
"eslint": "eslint --quiet lib/**/**.js test/**/**.js",
|