All files / apps / api/src / server / ratelimit client.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17          64x   64x         114x   114x    
// The only reader of the Rate Limiting bindings (design 8.2, G7). Counts are approximate and per
// Cloudflare location (developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit).
 
/** Bootstrap: 10 a minute per Firebase account. */
export async function isWithinBootstrapLimit(env: Env, firebaseUid: string): Promise<boolean> {
  const { success } = await env.BOOTSTRAP_LIMITER.limit({ key: firebaseUid })
 
  return success
}
 
/** The high per-IP ceiling: the whole office shares one IP. */
export async function isWithinIpCeiling(env: Env, ip: string): Promise<boolean> {
  const { success } = await env.IP_LIMITER.limit({ key: ip })
 
  return success
}