@wrcb/cb-common 1.0.153 → 1.0.155
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.
|
@@ -6,5 +6,5 @@ interface ApiLimiterOptions {
|
|
|
6
6
|
max?: number;
|
|
7
7
|
prefix?: string;
|
|
8
8
|
}
|
|
9
|
-
export declare function createRateApiLimiter(options: ApiLimiterOptions): import("express-rate-limit").RateLimitRequestHandler;
|
|
9
|
+
export declare function createRateApiLimiter(options: ApiLimiterOptions): ((req: any, res: any, next: any) => any) | import("express-rate-limit").RateLimitRequestHandler;
|
|
10
10
|
export {};
|
|
@@ -19,6 +19,11 @@ const ioredis_1 = __importDefault(require("ioredis"));
|
|
|
19
19
|
const tooManyRequestsError_1 = require("../errors/tooManyRequestsError");
|
|
20
20
|
function createRateApiLimiter(options) {
|
|
21
21
|
const { errorMessage = 'Calma lá, são muitas requisições. Tente novamente mais tarde!', windowMinutes = 3, max = 5, prefix = 'rl:', redisHost, redisPort } = options;
|
|
22
|
+
// 🧪 Desativar rate limiter em testes
|
|
23
|
+
if (process.env.NODE_ENV === 'test') {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
return (req, res, next) => next();
|
|
26
|
+
}
|
|
22
27
|
const redisClient = new ioredis_1.default({
|
|
23
28
|
host: redisHost,
|
|
24
29
|
port: redisPort
|
|
@@ -55,12 +60,3 @@ function createRateApiLimiter(options) {
|
|
|
55
60
|
});
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
|
-
// store: new RedisStore({
|
|
59
|
-
// prefix,
|
|
60
|
-
// // 👇 Corrigido para aceitar `args` como string
|
|
61
|
-
// sendCommand: (command: string, args: string) => {
|
|
62
|
-
// // 👇 ioredis.call() espera o comando + argumentos como lista separada
|
|
63
|
-
// const splitArgs = Array.isArray(args) ? args : [args]
|
|
64
|
-
// return redisClient.call(command, ...splitArgs) as Promise<any>
|
|
65
|
-
// }
|
|
66
|
-
// }),
|