From 0f3db42c3d4b679b1c2277f70422e88eddec7cad Mon Sep 17 00:00:00 2001 From: Alexey Yarmosh Date: Fri, 27 Sep 2024 13:00:55 +0200 Subject: [PATCH] feat: add block duration --- src/lib/rate-limiter/rate-limiter-get.ts | 2 ++ test/tests/integration/ratelimit.test.ts | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/rate-limiter/rate-limiter-get.ts b/src/lib/rate-limiter/rate-limiter-get.ts index ef9edb41..2c57fc1a 100644 --- a/src/lib/rate-limiter/rate-limiter-get.ts +++ b/src/lib/rate-limiter/rate-limiter-get.ts @@ -13,6 +13,7 @@ export const anonymousRateLimiter = new RateLimiterRedis({ keyPrefix: 'rate:get:anon', points: config.get('measurement.rateLimit.get.anonymousLimit'), duration: config.get('measurement.rateLimit.get.reset'), + blockDuration: 5, }); export const authenticatedRateLimiter = new RateLimiterRedis({ @@ -20,6 +21,7 @@ export const authenticatedRateLimiter = new RateLimiterRedis({ keyPrefix: 'rate:get:auth', points: config.get('measurement.rateLimit.get.authenticatedLimit'), duration: config.get('measurement.rateLimit.get.reset'), + blockDuration: 5, }); const getRateLimiter = (ctx: ExtendedContext, extraId?: string): { diff --git a/test/tests/integration/ratelimit.test.ts b/test/tests/integration/ratelimit.test.ts index b0147e4f..8659168a 100644 --- a/test/tests/integration/ratelimit.test.ts +++ b/test/tests/integration/ratelimit.test.ts @@ -274,7 +274,6 @@ describe('rate limiter', () => { type: 'ping', target: 'jsdelivr.com', }).expect(202) as Response; - console.log(id); await authenticatedGetRateLimiter.set(`89da69bd-a236-4ab7-9c5d-b5f52ce09959:${id}`, 1000, 0); const response = await requestAgent.get(`/v1/measurements/${id}`) .set('Authorization', 'Bearer qz5kdukfcr3vggv3xbujvjwvirkpkkpx')