Express middleware for IP-based rate limiting with flexible configuration options and multiple storage backends
Overall
score
96%
Build a small Express application that exposes a single GET endpoint guarded by rate limiting middleware. The middleware must tolerate backend store failures when configured to fail-open, and must pass runtime errors through Express error handling rather than hiding them.
{ "ok": true, "fallback": "store-unavailable" } when fail-open mode is enabled, and the supplied logger is invoked once with the store error. @test{ "error": "store failure" }. @testError("limit failure") and that error is forwarded to Express error handling, producing an HTTP 500 response whose body includes "limit failure". @test@generates
export interface StoreLike {
increment(key: string): Promise<{ totalHits: number; resetTime?: Date }>;
decrement?(key: string): Promise<void>;
resetKey?(key: string): Promise<void>;
}
export interface BuildOptions {
store: StoreLike;
failOpen?: boolean;
logger?: (error: unknown) => void;
limit?: number;
windowMs?: number;
}
export function createApp(options: BuildOptions): import("express").Express;HTTP server and routing framework to expose the endpoint and error middleware.
Rate limiting middleware that supports fail-open behavior for store errors and passes custom handler errors through Express.
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