express-rate-limit

Basic IP rate-limiting middleware for Express to throttle repeated requests and protect public APIs and sensitive endpoints.

Library
npm
v8.7.1
3,313 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
85 /100 Excellent
Development Activity 92
Maintenance 84
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 →
89 /100 Excellent
Architecture 88
Code Quality 90
Innovation 88
Learning Curve 90

express-rate-limit is a small, dependency-light middleware for the Express web framework that caps how many requests a client can make within a configurable time window. Drop it into an app to shield public APIs, login flows, and password-reset endpoints from brute-force attempts, scraping, and accidental request floods.

It ships with an in-memory store for single-process apps and a well-defined Store interface for scaling across processes with Redis, Memcached, or other backends. Response headers follow the IETF RateLimit draft standards (draft-6, draft-7, and draft-8), and nearly every option—limits, key generation, skip rules, and handlers—can be a synchronous or async function.

What You Get

  • A configurable middleware factory (rateLimit) that enforces a request limit over a windowMs time window
  • A built-in in-memory store plus a documented Store interface for Redis, Memcached, and other shared backends
  • Standards-compliant RateLimit response headers (IETF draft-6, draft-7, and draft-8) with legacy X-RateLimit support
  • Async-capable options for limits, key generation, skip rules, and custom limit-reached handlers
  • Exported helpers including MemoryStore, ipKeyGenerator, and SECOND/MINUTE/HOUR/DAY time constants

Common Use Cases

  • Throttling public REST APIs to prevent abuse and control infrastructure costs
  • Protecting authentication endpoints such as login and password reset against brute-force attacks
  • Rate-limiting form submissions, search, and other expensive endpoints against scraping or floods
  • Sharing hit counts across a multi-node deployment via an external Redis or Memcached store

Under The Hood

Architecture — The public entry point (source/index.ts) re-exports a single rateLimit factory from source/rate-limit.ts, alongside MemoryStore, ipKeyGenerator, and time constants. rate-limit.ts parses and normalizes options, wraps legacy callback-style stores in a promisified adapter (isLegacyStore/promisifyStore), and returns an Express RequestHandler. On each request the handler derives a client key (keyGenerator, IP-based by default via source/ip-key-generator.ts), calls store.increment(key), evaluates the hit count against the resolved limit, attaches rate-limit info to the request object, and sets standards headers from source/headers.ts before either calling next() or invoking the limit-reached handler. State lives behind the Store abstraction, with source/memory-store.ts providing the default in-process implementation.

Tech Stack — Written entirely in TypeScript (100% of the codebase), shipped as dual ESM/CJS via esbuild with types bundled by dts-bundle-generator. Runtime dependencies are minimal: debug for diagnostics and ip-address for IPv6 handling, with express declared only as a peer dependency (>= 4.11). Tooling uses Biome for linting/formatting, Jest with ts-jest for tests, Husky and lint-staged for pre-commit checks, and Mintlify for hosted docs. Targets Node >= 16.

Code Quality — The library is well-tested: test/library contains focused suites for the middleware, memory store, headers, validation, options, key generation, and logging, with the middleware suite alone exceeding 31KB, plus a separate external-integration test harness. Source files are small, single-responsibility modules with JSDoc on internal helpers, strong typing throughout (source/types.ts), and a dedicated validations.ts that proactively warns about common misconfigurations. Error handling is explicit, including a configurable passOnStoreError policy for store outages.

API Design — The developer experience is excellent. Getting started requires a single rateLimit({ windowMs, limit }) call passed to app.use(), and the option surface is broad but discoverable, with nearly every field accepting a static value or a sync/async function. Naming is consistent and intent-revealing (windowMs, limit, keyGenerator, skip, handler), readable time constants reduce magic numbers, and the built-in validation layer plus thorough hosted documentation make misconfiguration easy to catch and correct.

Used by 30 apps in this directory

TypeScript
26%
AGPL 3.0

Omnivore

Bookmarks Archiving · Knowledge Management · Note Taking

16,356

Self-hosted read-it-later platform with highlights, newsletters, PDFs, and seamless Obsidian and Logseq integration.

View details
90
Repo Health
74
Technical
65
Dependency
Built with
TypeScript 26%
JavaScript 24%
HTML 20%
Updated 2 days ago
TypeScript
99%
AGPL 3.0

Pangolin

Networking

23,187

An open-source, identity-based zero-trust remote access platform built on WireGuard — a self-hostable alternative to Cloudflare Tunnel and Twingate with SSO, OIDC, and tunneled reverse proxying.

View details
87
Repo Health
68
Technical
68
Dependency
Built with
TypeScript 99%
Updated 2 days ago
JavaScript
98%
Apache 2.0

Parse Server

Databases · Developer Tools

21,401

Self-hosted Backend-as-a-Service for Node.js with REST, GraphQL, real-time Live Query, cloud code, and pluggable adapters for any infrastructure.

View details
98
Repo Health
81
Technical
70
Dependency
Built with
JavaScript 98%
Updated 2 days ago
TypeScript
91%
AGPL 3.0

PeerTube

Social Media

15,362

A federated, ActivityPub-based video hosting platform built by Framasoft — self-hostable instances interconnect into a network with no vendor lock-in, P2P-assisted streaming, and no ads.

View details
96
Repo Health
75
Technical
66
Dependency
Built with
TypeScript 91%
Updated 1 weeks ago
TypeScript
90%
MIT

Plasmic

CMS · Design Tools · Low Code Platforms

7,125

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript 90%
Updated 2 days ago
TypeScript
98%
MIT

Promptfoo

AI Development

26,358

An open-source CLI and library for evaluating and red-teaming LLM applications — replace trial-and-error prompt engineering with systematic evals, vulnerability scanning, and CI/CD integration.

View details
90
Repo Health
73
Technical
67
Dependency
Built with
TypeScript 98%
Updated yesterday
TypeScript
97%
Other

Rocket.Chat

Team Chat

46,304

The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.

View details
96
Repo Health
79
Technical
63
Dependency
Built with
TypeScript 97%
Updated yesterday
TypeScript
97%
Apache 2.0

Unleash

Ab Testing Experimentation · Developer Tools · Devops

13,899

The open-source feature management platform that lets you ship code to production and control who sees it — without redeploying.

View details
91
Repo Health
84
Technical
69
Dependency
Built with
TypeScript 97%
Updated 2 days ago
TypeScript
72%
Apache 2.0

Valmis

AI Agents

108

A security-focused, self-hostable AI agent platform for production work — agents run in isolated containers that access credentials only through a host-side proxy, so the AI itself never sees API keys or plaintext credentials.

View details
51
Repo Health
69
Technical
70
Dependency
Built with
TypeScript 72%
Svelte 27%
Updated 1 months 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