@universal-rate-limit/express
v1.1.0
Published
Express middleware for universal-rate-limit
Maintainers
Readme
Express middleware for universal-rate-limit — a zero-dependency rate limiter built on web standards. Supports fixed-window and sliding-window algorithms, pluggable stores (memory, Redis, or your own), and IETF-compliant rate limit headers out of the box.
Install
npm install @universal-rate-limit/expressUsage
import express from 'express';
import { expressRateLimit } from '@universal-rate-limit/express';
const app = express();
// Apply to all routes
app.use(
expressRateLimit({
windowMs: 60_000, // 1 minute
limit: 60 // 60 requests per window
})
);
// Or apply to specific routes
app.use(
'/api',
expressRateLimit({
windowMs: 60_000,
limit: 30
})
);
app.listen(3000);Options
Accepts all core options — windowMs, limit, algorithm, store, keyGenerator, skip, handler, message, statusCode, headers, and passOnStoreError.
Example
See examples/express for a complete working app with integration tests.
Documentation
License
MIT
