Skip to content

Commit

Permalink
feat: add block duration
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Sep 27, 2024
1 parent 33b078e commit 0f3db42
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/lib/rate-limiter/rate-limiter-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ export const anonymousRateLimiter = new RateLimiterRedis({
keyPrefix: 'rate:get:anon',
points: config.get<number>('measurement.rateLimit.get.anonymousLimit'),
duration: config.get<number>('measurement.rateLimit.get.reset'),
blockDuration: 5,
});

export const authenticatedRateLimiter = new RateLimiterRedis({
storeClient: redisClient,
keyPrefix: 'rate:get:auth',
points: config.get<number>('measurement.rateLimit.get.authenticatedLimit'),
duration: config.get<number>('measurement.rateLimit.get.reset'),
blockDuration: 5,
});

const getRateLimiter = (ctx: ExtendedContext, extraId?: string): {
Expand Down
1 change: 0 additions & 1 deletion test/tests/integration/ratelimit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 0f3db42

Please sign in to comment.