High-performance Node.js rate limiting library — from of throttled-py.
Supports five algorithms (Fixed Window, Sliding Window, Token Bucket, Leaky Bucket & GCRA) and two storage backends (Redis, In-Memory).
npm install throttled-nodejsimport { Throttled } from 'throttled-nodejs';
const throttle = new Throttled({ quota: '100/s' });
const result = throttle.limit('/api');
if (result.limited) {
console.log(`Rate limited. Retry after ${result.state.retryAfter}s`);
} else {
console.log(`Allowed. ${result.state.remaining} remaining`);
}See the full documentation for:
- Function Call
- Decorator
- Context Manager
- Wait & Retry
- Store Backends
- Specifying Algorithms
- Quota Configuration
- Hooks
- Store Configuration
- OpenTelemetry
- API Reference
- Synchronous & Asynchronous — Works with both sync and
async/awaitcode - Thread-safe storage — In-Memory (LRU + TTL) and Redis (standalone / sentinel / cluster)
- Five algorithms — Fixed Window, Sliding Window, Token Bucket, Leaky Bucket, GCRA
- Flexible quota — DSL string
"100/s"or programmaticQuotaobjects - Three call modes — Function call, decorator, and context manager (
enter()/exit()) - Wait & Retry — Automatic retry with configurable timeout
- Hook system — Middleware pattern for observability, timing, and custom logic
- OpenTelemetry — Optional metrics integration
- Utils —
TimerandBenchmarkutilities
MIT