ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
16
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(middleware): separate rate limits for test env

byarielm.fyi fdacc4ee b03d9004

verified
+9 -6
+9 -6
packages/api/src/middleware/rateLimit.ts
··· 108 108 * Predefined rate limiters for common use cases 109 109 */ 110 110 111 - // General API rate limit: 60 requests per minute 111 + // Check if we're in test environment 112 + const isTestEnv = process.env.NODE_ENV === 'test' || process.env.VITEST === 'true'; 113 + 114 + // General API rate limit: 60 requests per minute (1000 in tests) 112 115 export const apiRateLimit = rateLimiter({ 113 - maxRequests: 60, 116 + maxRequests: isTestEnv ? 1000 : 60, 114 117 windowMs: 60 * 1000, 115 118 message: 'Too many requests. Please try again later.', 116 119 }); 117 120 118 - // Search rate limit: 10 searches per minute (each can have 50 usernames) 121 + // Search rate limit: 10 searches per minute (100 in tests) 119 122 export const searchRateLimit = rateLimiter({ 120 - maxRequests: 10, 123 + maxRequests: isTestEnv ? 100 : 10, 121 124 windowMs: 60 * 1000, 122 125 message: 'Search limit reached. Please wait before searching again.', 123 126 }); 124 127 125 - // Follow rate limit: 100 follows per hour 128 + // Follow rate limit: 100 follows per hour (1000 in tests) 126 129 export const followRateLimit = rateLimiter({ 127 - maxRequests: 100, 130 + maxRequests: isTestEnv ? 1000 : 100, 128 131 windowMs: 60 * 60 * 1000, 129 132 message: 'Follow limit reached. Please try again later.', 130 133 });