Request throttling middleware for Express using a token bucket algorithm with sliding window refill. Version 2.0.0 is current stable. Enables per-route rate limiting with configurable burst capacity, rate, and key function (defaults to IP address). Supports half-requests and custom cost per request. Limitations: in-memory storage by default (not shared across processes), and race conditions when using custom external backends under high load. Recommended for single-process apps.
npm install express-throttleVerified import paths — ran on the pinned version, not inferred.
Basic Express app with three rate-limited routes using express-throttle middleware.
Use a shared external storage backend (e.g., Redis), but be aware of race conditions under high load. Alternatively, ensure sticky sessions.
Use `rate` for sliding window throttling instead of `period`.
Configure Express trust proxy settings and provide a custom `key` function that uses `req.connection.remoteAddress` or `req.headers['x-forwarded-for']`.
Use integer `cost` values to avoid fractional token counting.
Use in-memory storage for single-process apps, or wait for a future version with atomic operations.
Use `const throttle = require('express-throttle');` or `import * as throttle from 'express-throttle';`Use correct rate string like '10/m' for 10 per minute.
Run `npm install express-throttle` in your project directory.