/** * Rate Limiting Middleware * * Uses Upstash Redis for distributed rate limiting. * Supports per-API-key and per-IP limiting with configurable tiers. */ import type { Context, Next } from "hono"; export interface RateLimitConfig { /** Override requests per minute */ requestsPerMinute?: number; /** Skip rate limiting entirely */ skip?: boolean; /** Custom identifier function */ getIdentifier?: (c: Context) => string; } export interface RateLimitInfo { limit: number; remaining: number; reset: number; } /** * Rate limiting middleware using Upstash Redis. * * Limits requests based on API key (from X-API-Key header) or IP address. * Returns 429 Too Many Requests when limit exceeded. * * Response headers: * - X-RateLimit-Limit: Total requests allowed in window * - X-RateLimit-Remaining: Requests remaining * - X-RateLimit-Reset: Unix timestamp when limit resets */ export declare function createRateLimitMiddleware(config?: RateLimitConfig): (c: Context, next: Next) => Promise<(Response & import("hono").TypedResponse<{ error: string; retryAfter: number; }, 429, "json">) | undefined>; /** * Check rate limit status without consuming a request. * Useful for showing remaining quota to users. */ export declare function getRateLimitStatus(identifier: string): Promise; /** * Reset rate limit for an identifier. * Use with caution - mainly for admin/testing purposes. */ export declare function resetRateLimit(identifier: string): Promise; export declare const rateLimitMiddleware: (c: Context, next: Next) => Promise<(Response & import("hono").TypedResponse<{ error: string; retryAfter: number; }, 429, "json">) | undefined>;