Express middleware for IP-based rate limiting with flexible configuration options and multiple storage backends
Overall
score
96%
Expose an HTTP endpoint that applies two independent request quotas and surfaces draft-8 standard rate-limit metadata so clients can understand each quota and their hashed partition keys.
/quota response returns draft-8 RateLimit and RateLimit-Policy headers with quota names for both a route-wide window (1 minute, 20 requests) and a per-user window (10 seconds, 3 requests) @testRateLimit-Policy entries and two RateLimit entries, one per quota, rather than collapsing them into a single header @testRateLimit metadata exposes partition tokens that are not the raw client identifier (taken from the X-User-ID header when provided), confirming hashed partition keys in the draft-8 headers @testX-User-ID, the per-user quota blocks the fourth call with HTTP 429 while the route-wide quota still reports remaining capacity in its RateLimit entry @test@generates
import type { Express, RequestHandler } from "express";
/**
* Builds an Express server exposing a GET /quota endpoint.
* Attaches two rate limiters configured for draft-8 headers:
* - Route-wide: 20 requests per minute.
* - Per-user: 3 requests per 10 seconds keyed by X-User-ID.
*/
export function createServer(): Express;
/**
* Reusable middleware that applies both limiters so it can be mounted on other routes.
*/
export const applyQuotaLimits: RequestHandler;HTTP server framework for routing and response handling.
Draft-8 standard header emitting rate limiting middleware that supports multiple limiters with quota identifiers and hashed partition keys.
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