feat: set custom rate limit for 404s
This commit is contained in:
parent
02cd6f4b5f
commit
290a13cc31
1 changed files with 5 additions and 2 deletions
|
@ -10,12 +10,15 @@ const app = Fastify({ logger: true })
|
||||||
await app.register(import('@fastify/rate-limit'), {
|
await app.register(import('@fastify/rate-limit'), {
|
||||||
global: true,
|
global: true,
|
||||||
max: 25,
|
max: 25,
|
||||||
timeWindow: 1000,
|
timeWindow: 1000 * 60,
|
||||||
})
|
})
|
||||||
|
|
||||||
await app.setNotFoundHandler(
|
await app.setNotFoundHandler(
|
||||||
{
|
{
|
||||||
preHandler: app.rateLimit(),
|
preHandler: app.rateLimit({
|
||||||
|
max: 100,
|
||||||
|
timeWindow: 1000,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
function (request, reply) {
|
function (request, reply) {
|
||||||
reply.code(404).send({ nothing: 'to see here' })
|
reply.code(404).send({ nothing: 'to see here' })
|
||||||
|
|
Loading…
Reference in a new issue