Rate Limiting
Protect your APIs from abuse. Configure limits per route, user, or IP. Simple setup, powerful protection.
On this page
Rate Limiting That Protects
Add rate limiting to any route with one line.
Protect against abuse, ensure fair usage, and maintain performance.
It's This Simple
Add rate limiting with one line
typescript
Why Rate Limiting Matters
Without rate limiting, your API is vulnerable to abuse, DDoS attacks, and unfair usage. With rate limiting, you control access and protect resources.
Traditional rate limiting requires middleware setup, storage configuration, and manual tracking. We handle that automatically.
Without Rate Limiting
- •Vulnerable to abuse and DDoS
- •Unfair resource usage
- •Manual tracking required
- •Complex middleware setup
With MoroJS
- •Automatic abuse protection
- •Fair usage enforcement
- •One-line setup
- •Flexible per-route configuration
It's This Easy
Configure limits per route. Different limits for different endpoints.
Different limits for different endpoints
typescript
Why It Makes Sense
Protection
Protect against abuse, DDoS attacks, and resource exhaustion.
Fair Usage
Ensure fair resource distribution. Different limits for different users.
Simple
One line per route. Automatic tracking. Custom keys supported.
How It Works
MoroJS rate limiting tracks requests based on a key (IP, user ID, or custom) within a time window. When the limit is exceeded, requests are automatically rejected with a 429 status code and helpful headers.
Configuration
Basic Rate Limiting
typescript
Different Limits for Different Endpoints
typescript
Advanced Configuration
For advanced use cases, you can configure custom rate limit keys (by user ID, API key, etc.), dynamic limits based on user plans, and custom error responses.
Custom Rate Limit Keys
typescript
Custom Error Responses
typescript