feat: set custom rate limit for 404s

This commit is contained in:
Ayo Ayco 2025-08-07 18:47:27 +02:00
parent 02cd6f4b5f
commit 290a13cc31

View file

@ -10,12 +10,15 @@ const app = Fastify({ logger: true })
await app.register(import('@fastify/rate-limit'), {
global: true,
max: 25,
timeWindow: 1000,
timeWindow: 1000 * 60,
})
await app.setNotFoundHandler(
{
preHandler: app.rateLimit(),
preHandler: app.rateLimit({
max: 100,
timeWindow: 1000,
}),
},
function (request, reply) {
reply.code(404).send({ nothing: 'to see here' })