Merge pull request #664 from mendableai/nsc/manual-rate-limit
Some checks failed
Fly Deploy / Pre-deploy checks (push) Has been cancelled
Fly Deploy / Test Suite (push) Has been cancelled
Fly Deploy / Python SDK Tests (push) Has been cancelled
Fly Deploy / JavaScript SDK Tests (push) Has been cancelled
Fly Deploy / Go SDK Tests (push) Has been cancelled
Fly Deploy / Rust SDK Tests (push) Has been cancelled
Fly Deploy / Deploy app (push) Has been cancelled
Fly Deploy / Build and publish Python SDK (push) Has been cancelled
Fly Deploy / Build and publish JavaScript SDK (push) Has been cancelled
Fly Deploy / Build and publish Rust SDK (push) Has been cancelled

Manual Rate Limiter for select team ids
This commit is contained in:
Nicolas 2024-09-13 18:12:41 -04:00 committed by GitHub
commit 98de36feb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -104,6 +104,13 @@ export const devBRateLimiter = new RateLimiterRedis({
duration: 60, // Duration in seconds
});
export const manualRateLimiter = new RateLimiterRedis({
storeClient: redisRateLimitClient,
keyPrefix: "manual",
points: 2000,
duration: 60, // Duration in seconds
});
export const scrapeStatusRateLimiter = new RateLimiterRedis({
storeClient: redisRateLimitClient,
@ -114,6 +121,8 @@ export const scrapeStatusRateLimiter = new RateLimiterRedis({
const testSuiteTokens = ["a01ccae", "6254cf9", "0f96e673", "23befa1b", "69141c4"];
const manual = ["69be9e74-7624-4990-b20d-08e0acc70cf6"];
export function getRateLimiter(
mode: RateLimiterMode,
token: string,
@ -129,6 +138,10 @@ export function getRateLimiter(
return devBRateLimiter;
}
if(teamId && manual.includes(teamId)) {
return manualRateLimiter;
}
const rateLimitConfig = RATE_LIMITS[mode]; // {default : 5}
if (!rateLimitConfig) return serverRateLimiter;