How cloudkick/rate-limiter works
This small Node.js library applies per-IP request limits by path and HTTP method. Callers configure limits, then pass HTTP requests through the evaluator; allowed requests reach the supplied callback, while exceeded limits receive a 429 response. An Express adapter builds a limiter from rules and advances middleware only for requests that pass. Rule definitions and counters are in-memory state within the limiter. The runtime implementation is concentrated in lib/rate-limiter.js; the graph separates its main responsibilities without implying separate storage services.
Main entry points: rate-limiter.js Express adapter · index.js Public exports
Components 8
Other components
- Application caller
- Public exports
index.js - Limits and counters
lib/rate-limiter.js - Request evaluator
lib/rate-limiter.js - 429 responder
lib/rate-limiter.js - Express adapter
lib/rate-limiter.js - Express next
- Allowed callback
Connections 10
- Application caller → Public exports: loads API
README.md - Public exports → Limits and counters: exports limiter
index.js - Application caller → Limits and counters: adds or removes limits
README.md - Application caller → Request evaluator: submits request
README.md - Request evaluator → 429 responder: invokes handler
lib/rate-limiter.js - Request evaluator → Allowed callback: calls if allowed
README.md - Application caller → Express adapter: configures rules
README.md - Express adapter → Limits and counters: adds configured limits
lib/rate-limiter.js - Express adapter → Request evaluator: processes request
lib/rate-limiter.js - Express adapter → Express next: advances if allowed
lib/rate-limiter.js