Express middleware for IP-based rate limiting with flexible configuration options and multiple storage backends
Overall
score
96%
Build an Express router that enforces a request quota (using the provided windowMs and maxHits options) and exposes the current rate-limit metadata to callers on a single GET /widgets route.
GET /widgets request is within the quota window, respond 200 with a JSON body containing limit, used, remaining, and resetTime (ISO string) taken from the rate-limit metadata, and emit standard rate-limit headers (RateLimit, RateLimit-Policy) that reflect the same numbers. @testGET /widgets responds 429 with JSON including the metadata fields plus retryAfterSeconds (derived from the metadata reset time), and sets Retry-After to match that value. @testrateLimit when omitted) and is the source of the response payloads, rather than any default property. @test@generates
export interface RateLimitRouterOptions {
windowMs: number;
maxHits: number;
requestProperty?: string;
headerDraft?: "draft-6" | "draft-7" | "draft-8" | "legacy";
}
export function createRateLimitedRouter(
options: RateLimitRouterOptions
): import("express").Router;HTTP server framework used to build the router.
Provides request counting, metadata attachment, and rate-limit headers.
Install with Tessl CLI
npx tessl i tessl/npm-express-rate-limitevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10