@wrcb/cb-common 1.0.126 → 1.0.128

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,10 +9,7 @@ const rate_limit_redis_1 = __importDefault(require("rate-limit-redis"));
9
9
  const ioredis_1 = __importDefault(require("ioredis"));
10
10
  const tooManyRequestsError_1 = require("../errors/tooManyRequestsError");
11
11
  function createRateApiLimiter(options) {
12
- const { errorMessage = 'Calma lá, são muitas requisições. Tente novamente mais tarde!', windowMinutes = 3, // 🕒 Janela de tempo em minutos
13
- max = 5, // 🚫 Máx. de requisições por IP
14
- prefix = 'rl:', // 🏷 Prefixo usado nas chaves Redis
15
- redisHost, redisPort } = options;
12
+ const { errorMessage = 'Calma lá, são muitas requisições. Tente novamente mais tarde!', windowMinutes = 3, max = 5, prefix = 'rl:', redisHost, redisPort } = options;
16
13
  const redisClient = new ioredis_1.default({
17
14
  host: redisHost,
18
15
  port: redisPort
@@ -24,11 +21,10 @@ function createRateApiLimiter(options) {
24
21
  legacyHeaders: false,
25
22
  store: new rate_limit_redis_1.default({
26
23
  prefix,
27
- // 👇 Corrigido para aceitar `args` como string
24
+ // Agora compatível com o tipo real do rate-limit-redis
25
+ // @ts-ignore
28
26
  sendCommand: (command, args) => {
29
- // 👇 ioredis.call() espera o comando + argumentos como lista separada
30
- const splitArgs = Array.isArray(args) ? args : [args];
31
- return redisClient.call(command, ...splitArgs);
27
+ return redisClient.call(command, ...args);
32
28
  }
33
29
  }),
34
30
  handler: function handleRateLimitExceeded(req, res, next) {
@@ -36,3 +32,12 @@ function createRateApiLimiter(options) {
36
32
  }
37
33
  });
38
34
  }
35
+ // store: new RedisStore({
36
+ // prefix,
37
+ // // 👇 Corrigido para aceitar `args` como string
38
+ // sendCommand: (command: string, args: string) => {
39
+ // // 👇 ioredis.call() espera o comando + argumentos como lista separada
40
+ // const splitArgs = Array.isArray(args) ? args : [args]
41
+ // return redisClient.call(command, ...splitArgs) as Promise<any>
42
+ // }
43
+ // }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrcb/cb-common",
3
- "version": "1.0.126",
3
+ "version": "1.0.128",
4
4
  "description": "Common resources between services",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",