
@fastify/rate-limit
#Application Protection#Application Security
An Application Security Posture Management platform that provides visibility, security controls, and automated workflows across the software development lifecycle from code to cloud.
An Efficient Low Overhead Rate Limiter for Your Routes
This is a low overhead rate limiter designed specifically for your routes.
This plugin will add an onRequest hook for rate limiting
This plugin introduces an onRequest hook that checks whether a client, identified by their IP address, has exceeded the maximum number of requests within a specified timeWindow.
Usage: To use this plugin, register it and, if needed, provide custom options.
Example:
```javascript
import Fastify from 'fastify'
const fastify = Fastify()
await fastify.register(import('@fastify/rate-limit'), { max: 100, timeWindow: '1 minute' })
fastify.get('/', (request, reply) => { reply.send({ hello: 'world' }) })
fastify.listen({ port: 3000 }, err => { if (err) throw err
console.log('Server listening at http://localhost:3000') })
```
Requirements:
1. Keep all technical terms and concepts exactly as they are
2. Make the language clearer and more accessible
3. Keep the same content structure and format
4. Do not add or remove any information
5. Maintain similar length if very small length of content then add little more content