feat: update rate limits (25 max, within 5 minutes)

This commit is contained in:
Ayo Ayco 2025-08-07 19:23:33 +02:00
parent 4b46ba1ec3
commit d9fdf67c8a

View file

@ -7,18 +7,23 @@ import { fileURLToPath } from 'node:url'
import { handler as ssrHandler } from './dist/server/entry.mjs' import { handler as ssrHandler } from './dist/server/entry.mjs'
const app = Fastify({ logger: true }) 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 * 5,
}) })
.register(fastifyStatic, {
root: fileURLToPath(new URL('./dist/client', import.meta.url)),
})
.register(fastifyMiddie)
app.use(ssrHandler)
await app.setNotFoundHandler( await app.setNotFoundHandler(
{ {
preHandler: app.rateLimit({ preHandler: app.rateLimit(),
max: 10,
timeWindow: 1000,
}),
}, },
function (request, reply) { function (request, reply) {
reply.code(404).send({ nothing: 'to see here' }) reply.code(404).send({ nothing: 'to see here' })
@ -33,11 +38,4 @@ await app.setErrorHandler(function (error, request, reply) {
reply.send(error) reply.send(error)
}) })
await app
.register(fastifyStatic, {
root: fileURLToPath(new URL('./dist/client', import.meta.url)),
})
.register(fastifyMiddie)
app.use(ssrHandler)
app.listen({ port: 4321 }) app.listen({ port: 4321 })