@nestjs/throttler

The official NestJS rate-limiting module for Express, Fastify, GraphQL, WebSockets, and RPC

Library
npm
v6.5.0
698stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
82/100Excellent
Development Activity96
Maintenance84
Community60
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture80
Code Quality82
Innovation72
Learning Curve84

@nestjs/throttler is NestJS’s official rate-limiting module, providing a ThrottlerGuard and @Throttle() decorator that apply request-rate limits consistently across every transport NestJS supports — HTTP (Express or Fastify), GraphQL resolvers, WebSocket gateways, and microservice RPC handlers — through one shared API rather than a separate rate-limiting library per transport.

It’s built as a standard NestJS dynamic module (ThrottlerModule.forRoot()/forRootAsync()) with a pluggable storage interface, so the default in-memory limiter can be swapped for Redis or another distributed store when running multiple application instances behind a load balancer.

What You Get

  • ThrottlerModule.forRoot()/forRootAsync() for global rate-limit configuration, following standard NestJS dynamic-module conventions
  • A ThrottlerGuard that can be applied globally, per-controller, or per-route via NestJS’s guard system
  • @Throttle() and @SkipThrottle() decorators for overriding or exempting specific routes from the global limit
  • Multiple named throttler configurations (e.g. short/medium/long windows) applied simultaneously to the same route
  • Uniform behavior across HTTP (Express/Fastify), GraphQL resolvers, WebSocket gateways, and RPC/microservice handlers
  • A pluggable ThrottlerStorage interface so the default in-memory store can be replaced with Redis or another distributed backend

Common Use Cases

  • Protecting public API endpoints (login, signup, password reset) from brute-force and credential-stuffing attempts
  • Applying different rate-limit tiers to different routes (e.g. stricter limits on auth routes, looser on general API routes)
  • Rate-limiting GraphQL resolvers or WebSocket gateway events, not just REST endpoints
  • Enforcing consistent request quotas across a horizontally-scaled NestJS deployment via a shared Redis-backed throttler storage
  • Exempting internal health-check or webhook routes from a global rate limit via @SkipThrottle()

Under The Hood

Architecture — The module follows the standard NestJS dynamic-module pattern: throttler.module.ts wires up forRoot/forRootAsync and registers providers, throttler.guard.ts implements the ThrottlerGuard (a NestJS CanActivate guard) that inspects the current execution context — HTTP request, GraphQL context, WS client, or RPC context — to extract a tracking key and check it against configured limits, and throttler.service.ts holds the core rate-tracking logic against the pluggable ThrottlerStorage interface (throttler-storage.interface.ts), with hash.ts generating storage keys. throttler.decorator.ts implements @Throttle()/@SkipThrottle() using NestJS’s metadata/reflection system to let the guard read per-route overrides.

Tech Stack — TypeScript, built directly against @nestjs/core/@nestjs/common as peer dependencies, with no rate-limiting algorithm dependency of its own — the storage abstraction means Redis-backed limiting is added via a separate community storage adapter rather than a bundled client. Managed under the official nestjs GitHub organization with renovate.json for automated dependency updates.

Code Quality — Core logic has colocated spec files (throttler.guard.spec.ts, throttler.service.spec.ts) alongside a broader test/ suite exercising each supported transport (HTTP, GraphQL, WS, RPC) to confirm the guard behaves consistently across all of them — the main risk area for a cross-transport library. As an official @nestjs/* package it follows the framework’s own release cadence and conventions (CHANGELOG, semantic versioning, CODE_OF_CONDUCT/CONTRIBUTING docs) and has sustained active, well-maintained development.

API Design — Adoption is typically two lines: register ThrottlerModule.forRoot([{ ttl, limit }]) at the module level and apply ThrottlerGuard globally via APP_GUARD, after which every route is protected without per-route code. Overrides stay declarative via @Throttle({ default: { limit, ttl } })/@SkipThrottle() decorators rather than imperative guard logic, keeping rate-limit policy visible directly on the controller/route it applies to.

Used by 12 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,411

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday
TypeScript
74%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,153

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
71
Dependency
Built with
TypeScript74%
HTML23%
Updated yesterday
TypeScript
95%
AGPL 3.0

HeyForm

Forms Surveys · No Code Platforms

8,938

Open-source conversational form builder with AI generation, conditional logic, and 30+ integrations — self-host with full data ownership.

View details
86
Repo Health
67
Technical
69
Dependency
Built with
TypeScript95%
Updated today
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
TypeScript
64%
Other

NocoDB

No Code Platforms · Databases · Low Code Platforms

64,586

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript64%
Vue31%
Updated today
TypeScript
98%
Other

Novu

Developer Tools

39,615

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
65
Dependency
Built with
TypeScript98%
Updated today

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

Search