From 5606fe587068090bf1c7e55368b1e044e34f0b09 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 26 Aug 2024 16:05:11 -0300 Subject: [PATCH] Nick: --- apps/api/src/controllers/auth.ts | 3 ++- apps/api/src/services/rate-limiter.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts index ac60dc53..151733c0 100644 --- a/apps/api/src/controllers/auth.ts +++ b/apps/api/src/controllers/auth.ts @@ -222,7 +222,8 @@ export async function supaAuthenticateUser( rateLimiter = getRateLimiter( RateLimiterMode.Scrape, token, - subscriptionData.plan + subscriptionData.plan, + teamId ); break; case RateLimiterMode.Search: diff --git a/apps/api/src/services/rate-limiter.ts b/apps/api/src/services/rate-limiter.ts index cd923c4c..d96da069 100644 --- a/apps/api/src/services/rate-limiter.ts +++ b/apps/api/src/services/rate-limiter.ts @@ -84,16 +84,28 @@ export const testSuiteRateLimiter = new RateLimiterRedis({ duration: 60, // Duration in seconds }); +export const devBRateLimiter = new RateLimiterRedis({ + storeClient: redisRateLimitClient, + keyPrefix: "dev-b", + points: 1200, + duration: 60, // Duration in seconds +}); + export function getRateLimiter( mode: RateLimiterMode, token: string, - plan?: string + plan?: string, + teamId?: string ) { if (token.includes("a01ccae") || token.includes("6254cf9") || token.includes("0f96e673")) { return testSuiteRateLimiter; } + if(teamId === process.env.DEV_B_TEAM_ID) { + return devBRateLimiter; + } + const rateLimitConfig = RATE_LIMITS[mode]; // {default : 5} if (!rateLimitConfig) return serverRateLimiter;