A generic Redis-backed rate limiting tool built on top of ioredis. Current stable version is 3.1.1. Provides three limiting modes (binary, n-ary, uniform), batch operations, dynamic key generation, and minimum interval control. Fully tested with 100% coverage. Designed for Node.js environments with ioredis v5.8.2+. Differentiators include flexible modes, batch operations, and a simple API that can be used as Express middleware or standalone.
npm install ioredis-ratelimitNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a rate limiter allowing 10 requests per second and demonstrates consuming and checking quota.
Use ES module syntax (import/export) and ensure "type": "module" in package.json.
Review documentation for mode behavior; consider using 'uniform' mode for smoother limiting.
When using key as function, pass id to ratelimiter(id) to generate per-user keys.
Wrap ratelimiter calls in try-catch and return 429 response in Express/other middleware.
Set TTL to duration or do not set it unless you have specific persistence needs.
Add 'type': 'module' to package.json, or use dynamic import().
Use: import RateLimiter from 'ioredis-ratelimit'
Catch the error and respond with appropriate status (e.g., 429 HTTP status). Customize via error option.
Call RateLimiter({...}) without new since it's a factory function.