( bucketName: string, userId: string | undefined, request: NextRequest, config: TokenBucketConfig = DEFAULT_USER_ROUTE_LIMIT )
| 79 | * traffic is still throttled per-IP rather than sharing one global bucket. |
| 80 | */ |
| 81 | export 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 | } |
no test coverage detected