How to use
If you want to start restricting specific routes, you can import theRateLimit class from the plugin and then use it as follows:
src/api/middlewares.ts
src/api/middlewares.ts
Built-in IP Rate Limiting
For the common use case of IP-based rate limiting, V3 includes a ready-to-useipRateLimit middleware:
src/api/middlewares.ts
ipRateLimit middleware automatically:
- Extracts the client IP address
- Sets appropriate rate limit headers (X-RateLimit-Limit,X-RateLimit-Remaining)
- Returns a 429 status when the limit is exceeded
options object with the same options as the RateLimit class (limit, window, prefix).