Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

throttled-nodejs

npm version License

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).

Installation

npm install throttled-nodejs

Quick Start

import { 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`);
}

Documentation

See the full documentation for:

Features

  • Synchronous & Asynchronous — Works with both sync and async/await code
  • 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 programmatic Quota objects
  • 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
  • UtilsTimer and Benchmark utilities

License

MIT

About

throttle for nodejs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages