Express middleware for IP-based rate limiting with flexible configuration options and multiple storage backends
Overall
score
96%
A minimal Express server that demonstrates both standardized and legacy rate limit response headers for two endpoints. The server should make it obvious when standard headers are enabled versus legacy headers, and should surface retry timing when requests exceed the configured limits.
/standard in a 60-second window returns 200 OK and includes a RateLimit header that reports limit=3 and remaining=2, plus a RateLimit-Policy header describing the same 3-per-60s window (for example, 3;w=60). @test/standard (within that 60-second window) returns 429 with a Retry-After value that matches the remaining seconds until reset and a RateLimit header showing remaining=0. @test/legacy in a 30-second window returns 200 OK and includes X-RateLimit-Limit: 2, X-RateLimit-Remaining: 1, and an X-RateLimit-Reset timestamp (Unix seconds) within roughly 30 seconds in the future. @test/legacy within that 30-second window returns 429 with Retry-After matching the remaining seconds in the window and X-RateLimit-Remaining: 0. @test/standard never include any X-RateLimit-* headers, and responses from /legacy omit RateLimit/RateLimit-Policy headers so each route only exposes its intended header format. @test@generates
import type { Express } from "express";
/**
* Creates an Express app that serves rate-limited routes.
*/
export function createApp(): Express;Hosts the HTTP server and routes.
Provides middleware that enforces request quotas and emits rate limit response 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