Visit Website

A low overhead rate limiter for your routes. This plugin will add an onRequest hook to check if a client (based on their IP address) has made too many requests in the given timeWindow. Usage: Register the plugin and, if required, pass some 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') }) ```

ALTERNATIVES