rate-limiter-flexible

Atomic and non-atomic counters and rate-limiting tools that protect against DoS and brute-force attacks at any scale

Library
npm
v11.2.3
3,596 stars
ISC

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
75 /100 Good
Development Activity 68
Maintenance 68
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 82
Code Quality 80
Innovation 74
Learning Curve 70

rate-limiter-flexible is a Node.js library for counting and limiting the number of events per key (IP address, user ID, API route, etc.), protecting applications from denial-of-service and brute-force attacks. It provides a unified API across a wide range of backing stores — Redis, Valkey, Memcached, MongoDB, MySQL, PostgreSQL, SQLite, DynamoDB, Prisma, Drizzle, etcd, in-process Memory, and Cluster/PM2 — so applications can start with an in-memory limiter and move to a distributed store without rewriting call sites.

Beyond basic point-consumption rate limiting, the library offers advanced composition primitives: RateLimiterUnion to combine multiple limiters as one, BurstyRateLimiter for traffic bursts, RateLimiterQueue for FIFO-ordered request queuing, block-and-insurance strategies for resilience when a backing store is unavailable, and black/white-list wrappers. It has no production dependencies in its core, ships bundled TypeScript declarations, and is used widely to protect login endpoints, APIs, and WebSocket connections from abuse.

What You Get

  • A unified consume/get/set/block/penalty/reward API that works identically across a dozen supported backing stores
  • Backends for Redis, Valkey, Memcached, MongoDB, MySQL, PostgreSQL, SQLite, DynamoDB, Prisma, Drizzle, etcd, in-process Memory, and Cluster/PM2
  • Composable strategies: RateLimiterUnion (combine limiters), BurstyRateLimiter (traffic bursts), RateLimiterQueue (FIFO queuing)
  • Resilience features: in-memory block strategy to reduce store round-trips, and an insurance limiter as a fallback if the primary store is down
  • Zero production dependencies in the core package, with bundled TypeScript type declarations
  • Documented middleware patterns for Express, Koa, and Hapi, plus community packages for GraphQL and NestJS

Common Use Cases

  • Protecting login and authentication endpoints from brute-force password-guessing attacks
  • Rate-limiting a public API per user or API key, with different limits for authorized vs. unauthorized traffic
  • Preventing WebSocket connection flooding by limiting connection attempts per client
  • Throttling third-party API calls or crawler/bot traffic to stay within upstream rate limits

Under The Hood

Architecture - The library is built around an abstract base (RateLimiterAbstract.js) that defines the shared point-consumption contract, with RateLimiterStoreAbstract.js extending it for store-backed limiters and each backend (Redis, Mongo, MySQL, Postgres, DynamoDB, Prisma, Drizzle, etcd, Memcache, Valkey, ValkeyGlide) implementing that contract as its own module under lib/; composition classes (RateLimiterUnion, BurstyRateLimiter, RateLimiterQueue, RLWrapperBlackAndWhite, RLWrapperTimeouts) wrap one or more limiter instances to add higher-level behavior without touching the store implementations. Tech Stack - Pure JavaScript with zero required production dependencies in the core; each store backend is an optional peer integration (works with ioredis/redis, @valkey/valkey-glide/iovalkey, mongodb/mongoose, mysql/mysql2, pg, sequelize/typeorm/knex, prisma, drizzle-orm, memcached), so consumers only pull in the client library for the store they use. Code Quality - The project has an extensive test/ suite with a dedicated test file per backend (e.g. RateLimiterRedis.test.js, RateLimiterMySQL.test.js, RateLimiterDynamo.test.js) plus component-level tests, reflecting the discipline needed to keep atomic-increment correctness across a dozen very different storage engines; 60 contributors and continuous releases (67 tagged versions) indicate sustained maintenance. API Design - Every limiter exposes the same consume(key, points) promise-based method regardless of backing store, so switching from RateLimiterMemory to RateLimiterRedis in production requires changing only the constructor call; the RateLimiterRes result object bundles msBeforeNext, remainingPoints, and consumedPoints in a form that maps directly onto standard rate-limit HTTP headers.

Used by 16 apps in this directory

TypeScript
97%
Other

nango

Authentication · Automation · Developer Tools

12,963

Build product integrations with AI using 800+ APIs — auth, proxy, and TypeScript functions on production-grade infrastructure.

View details
94
Repo Health
85
Technical
67
Dependency
Built with
TypeScript 97%
Updated 6 days ago
JavaScript
90%
Other

OpenSign

Digital Signiture

7,163

Self-host a full-featured DocuSign alternative with unlimited e-signatures, multi-signer workflows, and cryptographic PDF signing.

View details
83
Repo Health
61
Technical
69
Dependency
Built with
JavaScript 90%
Updated 6 days ago
TypeScript
98%
Other

Outline

Collaboration · Knowledge Management

41,045

A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript 98%
Updated 5 days ago
JavaScript
64%
AGPL 3.0

overleaf

Collaboration · Productivity

18,266

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
84
Repo Health
80
Technical
59
Dependency
Built with
JavaScript 64%
TypeScript 30%
Updated 1 months ago
TypeScript
100%
AGPL 3.0

RSSHub

Automation · Social Media

46,631

Turn any website into an RSS feed — social media, streaming platforms, and niche sites all become subscribable in seconds.

View details
94
Repo Health
82
Technical
71
Dependency
Built with
TypeScript 100%
Updated 5 days ago
TypeScript
98%
MIT

sigle

Blogging

489

A decentralized, open-source writing platform that permanently stores your stories on the Stacks blockchain and Arweave — where Web3 content creators own their words forever.

View details
81
Repo Health
78
Technical
69
Dependency
Built with
TypeScript 98%
Updated 2 weeks ago
JavaScript
86%
AGPL 3.0

SillyTavern

AI Assistants

34,869

The power-user LLM frontend that unifies dozens of AI backends with a rich scripting engine, immersive Visual Novel mode, and a thriving extension ecosystem.

View details
88
Repo Health
71
Technical
63
Dependency
Built with
JavaScript 86%
Updated 3 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers