@blocklet/rate-limit 1.16.54-beta-20251024-030947-6f2889bf → 1.16.54-beta-20251027-105624-dfa978f8
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/lib/index.js +6 -1
- package/package.json +6 -9
package/lib/index.js
CHANGED
|
@@ -13,6 +13,9 @@ const db_cache_1 = require("@abtnode/db-cache");
|
|
|
13
13
|
const express_rate_limit_1 = require("express-rate-limit");
|
|
14
14
|
const node_path_1 = __importDefault(require("node:path"));
|
|
15
15
|
const md5_1 = __importDefault(require("@abtnode/util/lib/md5"));
|
|
16
|
+
const isInTest = () => {
|
|
17
|
+
return process.env.NODE_ENV === 'test' || process.env.BABEL_ENV === 'test';
|
|
18
|
+
};
|
|
16
19
|
/**
|
|
17
20
|
* Store for rate limit
|
|
18
21
|
*/
|
|
@@ -23,7 +26,9 @@ class RateLimitStore {
|
|
|
23
26
|
prefix: 'rate',
|
|
24
27
|
ttl: options.windowMs || 1000 * 60,
|
|
25
28
|
redisUrl: options.redisUrl || serverUrls.redisUrl,
|
|
26
|
-
sqlitePath:
|
|
29
|
+
sqlitePath: isInTest()
|
|
30
|
+
? 'sqlite::memory:'
|
|
31
|
+
: options.sqlitePath || serverUrls.sqlitePath || node_path_1.default.join(process.env.BLOCKLET_DATA_DIR, 'rate-limit.db'),
|
|
27
32
|
}));
|
|
28
33
|
this.windowMs = options.windowMs;
|
|
29
34
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.54-beta-
|
|
6
|
+
"version": "1.16.54-beta-20251027-105624-dfa978f8",
|
|
7
7
|
"description": "rate limit middleware",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"typings": "lib/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"verify": "npm run lint:fix && npm run test && npm run build",
|
|
15
15
|
"lint": "eslint src tests",
|
|
16
16
|
"lint:fix": "npm run lint -- --fix",
|
|
17
|
-
"test": "bun test",
|
|
18
|
-
"coverage": "bun test --coverage",
|
|
17
|
+
"test": "bun test --bail --timeout 30000",
|
|
18
|
+
"coverage": "bun test --bail --timeout 30000 --coverage",
|
|
19
19
|
"clean": "rm -fr lib",
|
|
20
20
|
"prebuild": "npm run clean",
|
|
21
21
|
"build:blocklet-rate-limit": "npm run build",
|
|
@@ -25,26 +25,23 @@
|
|
|
25
25
|
"author": "blocklet<blocklet@arcblock.io>",
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@abtnode/db-cache": "1.16.54-beta-
|
|
29
|
-
"@abtnode/util": "1.16.54-beta-
|
|
28
|
+
"@abtnode/db-cache": "1.16.54-beta-20251027-105624-dfa978f8",
|
|
29
|
+
"@abtnode/util": "1.16.54-beta-20251027-105624-dfa978f8",
|
|
30
30
|
"express-rate-limit": "^7.5.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
34
34
|
"@types/express": "^5.0.0",
|
|
35
|
-
"@types/jest": "^29.5.13",
|
|
36
35
|
"@types/json-stable-stringify": "^1.0.36",
|
|
37
36
|
"@types/node": "^22.7.5",
|
|
38
37
|
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
|
39
38
|
"@typescript-eslint/parser": "^5.42.0",
|
|
40
39
|
"detect-port": "^1.5.1",
|
|
41
40
|
"eslint": "^8.57.0",
|
|
42
|
-
"jest": "^29.7.0",
|
|
43
41
|
"json-stable-stringify": "^1.0.1",
|
|
44
42
|
"prettier": "^3.3.2",
|
|
45
|
-
"ts-jest": "^29.2.5",
|
|
46
43
|
"ts-node": "^10.9.1",
|
|
47
44
|
"typescript": "^5.6.3"
|
|
48
45
|
},
|
|
49
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "03b0bb26807c6c427ca700f48566ecc913f1353e"
|
|
50
47
|
}
|