MCPcopy Index your code
hub / github.com/simstudioai/sim / enforceUserOrIpRateLimit

Function enforceUserOrIpRateLimit

apps/sim/lib/core/rate-limiter/route-helpers.ts:81–89  ·  view source on GitHub ↗
(
  bucketName: string,
  userId: string | undefined,
  request: NextRequest,
  config: TokenBucketConfig = DEFAULT_USER_ROUTE_LIMIT
)

Source from the content-addressed store, hash-verified

79 * traffic is still throttled per-IP rather than sharing one global bucket.
80 */
81export async function enforceUserOrIpRateLimit(
82 bucketName: string,
83 userId: string | undefined,
84 request: NextRequest,
85 config: TokenBucketConfig = DEFAULT_USER_ROUTE_LIMIT
86): Promise<NextResponse | null> {
87 if (userId) return enforceUserRateLimit(bucketName, userId, config)
88 return enforceIpRateLimit(bucketName, request, config)
89}

Callers 5

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 2

enforceUserRateLimitFunction · 0.85
enforceIpRateLimitFunction · 0.85

Tested by

no test coverage detected