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

Function buildRateLimitResponse

apps/sim/lib/core/rate-limiter/route-helpers.ts:24–39  ·  view source on GitHub ↗
(resetAt: Date)

Source from the content-addressed store, hash-verified

22}
23
24function buildRateLimitResponse(resetAt: Date): NextResponse {
25 const retryAfterSec = Math.max(1, Math.ceil((resetAt.getTime() - Date.now()) / 1000))
26 return NextResponse.json(
27 {
28 error: 'Rate limit exceeded',
29 retryAfter: resetAt.getTime(),
30 },
31 {
32 status: 429,
33 headers: {
34 'Retry-After': String(retryAfterSec),
35 'X-RateLimit-Reset': resetAt.toISOString(),
36 },
37 }
38 )
39}
40
41/**
42 * Apply a per-user token bucket to an authenticated route.

Callers 2

enforceUserRateLimitFunction · 0.85
enforceIpRateLimitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected