@wrcb/cb-common 1.0.136 → 1.0.139
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.
|
@@ -26,25 +26,17 @@ function createRateApiLimiter(options) {
|
|
|
26
26
|
// Verificando a versão do RedisStore
|
|
27
27
|
// Para versões mais recentes (>= 3.x)
|
|
28
28
|
if (typeof rate_limit_redis_1.default === 'function') {
|
|
29
|
-
return (0, express_rate_limit_1.default)({
|
|
30
|
-
windowMs: windowMinutes * 60 * 1000,
|
|
31
|
-
max,
|
|
32
|
-
standardHeaders: true,
|
|
33
|
-
legacyHeaders: false,
|
|
34
|
-
store: new rate_limit_redis_1.default({
|
|
29
|
+
return (0, express_rate_limit_1.default)(Object.assign(Object.assign({ windowMs: windowMinutes * 60 * 1000, max, standardHeaders: true, legacyHeaders: false }, { trustProxy: true }), { store: new rate_limit_redis_1.default({
|
|
35
30
|
prefix,
|
|
36
31
|
client: redisClient,
|
|
37
|
-
// Se necessário para versões específicas:
|
|
38
32
|
// @ts-ignore
|
|
39
33
|
sendCommand: (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
40
34
|
const [command, ...params] = args;
|
|
41
35
|
return redisClient.sendCommand(new ioredis_1.default.Command(command, params, { replyEncoding: 'utf8' }));
|
|
42
36
|
})
|
|
43
|
-
}),
|
|
44
|
-
handler: function handleRateLimitExceeded(req, res, next) {
|
|
37
|
+
}), handler: function handleRateLimitExceeded(req, res, next) {
|
|
45
38
|
next(new tooManyRequestsError_1.TooManyRequestsError(errorMessage));
|
|
46
|
-
}
|
|
47
|
-
});
|
|
39
|
+
} }));
|
|
48
40
|
}
|
|
49
41
|
// Para versões mais antigas
|
|
50
42
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrcb/cb-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.139",
|
|
4
4
|
"description": "Common resources between services",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -29,10 +29,12 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@types/cookie-session": "^2.0.49",
|
|
31
31
|
"@types/express": "^4.17.21",
|
|
32
|
+
"@types/express-rate-limit": "^6.0.2",
|
|
32
33
|
"@types/jsonwebtoken": "^9.0.6",
|
|
33
34
|
"@types/supertest": "^6.0.2",
|
|
34
35
|
"cookie-session": "^2.1.0",
|
|
35
36
|
"express": "^4.21.0",
|
|
37
|
+
"express-rate-limit": "^7.5.0",
|
|
36
38
|
"express-validator": "^7.1.0",
|
|
37
39
|
"ioredis": "^5.6.1",
|
|
38
40
|
"jsonwebtoken": "^9.0.2",
|