/** * Fixed-window per-key rate limiter with two backends: * * - **Upstash Redis** when `redis` config is supplied (durable, shared across * serverless instances). `@upstash/redis` is an optional peer dependency, * imported lazily so projects that don't use it never need to install it. * - **In-memory** otherwise (per-process). Fine for low-volume contact forms * on a single instance; on multi-instance serverless each instance keeps its * own window, so the effective limit is multiplied by the instance count. */ export interface RateLimitRedisConfig { url: string; token: string; } export interface RateLimitConfig { /** Max submissions per window per key. Default 5. */ maxAttempts?: number; /** Window length in ms. Default 1 hour. */ windowMs?: number; /** Namespace for keys. Default `'contact:'`. */ keyPrefix?: string; /** Supply to use Upstash Redis; omit for the in-memory backend. */ redis?: RateLimitRedisConfig; } export interface RateLimitResult { allowed: boolean; remaining: number; /** Ms until the window resets (only when `allowed` is false). */ retryAfterMs?: number; } export interface RateLimiter { check(key: string): Promise; } /** Build a rate limiter. Picks the Upstash backend when `config.redis` is set. */ export declare function createRateLimiter(config?: RateLimitConfig): RateLimiter; //# sourceMappingURL=rate-limit.d.ts.map