Open oscarhermoso opened 7 months ago
For debugging/logging/testing, it would be valuable to know the reason for being rate limited.
For example:
const status = await limiter.check(event); if (status.limited) { console.warn( 'Rate limit activated:', event.getClientAddress(), status.limitedBy // <-- new, expose which limiter blocked the request ); let response = new Response( `You are being rate limited. Please try after ${status.retryAfter} seconds.`, { status: 429, headers: { 'Retry-After': status.retryAfter.toString() } } ); return response; }
Proposed limitedBy property would have a type signature of something like this:
limitedBy
type LimitedBy = "IP" | "IPUA" | "cookies" | `plugins[${number}]` | undefined
For debugging/logging/testing, it would be valuable to know the reason for being rate limited.
For example:
Proposed
limitedBy
property would have a type signature of something like this: