Provides an Upstash Redis adapter for rate limiting, allowing developers to enforce distributed request limits using Lua scripts.
// Source: https://github.com/middleapi/orpc | License: MIT | Copyright 2023 oRPC
// Provided via justclaw.it.com; keep this notice with the code.
import type { Redis } from '@upstash/redis'
import type { BaseRedisRateLimiterOptions } from './base-redis'
import { BaseRedisRateLimiter } from './base-redis'
export interface UpstashRateLimiterOptions extends BaseRedisRateLimiterOptions {}
/**
* Rate limiter adapter for Upstash Redis. Enforces a fixed-window limit using a
* Redis Lua script, with optional blocking mode. It shares counters with `RedisRateLimiter`.
*
* @see {@link https://orpc.dev/docs/helpers/ratelimit#adapters | Rate Limit Helpers - Adapters}
*/
export class UpstashRateLimiter extends BaseRedisRateLimiter {
constructor(
private readonly redis: Redis,
private r
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key