From 2967b5994469ec83faba99135b696e4367cab67a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 5 Mar 2024 15:28:48 -0800 Subject: rate limiting --- lib/app.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/app.js b/lib/app.js index 4c4b7326..c1006455 100644 --- a/lib/app.js +++ b/lib/app.js @@ -19,6 +19,12 @@ const app = fastify({ maxParamLength: 500, }); +await app.register(import("@fastify/rate-limit"), { + max: 50, + timeWindow: 5000, + keyGenerator: (req) => req.headers["cf-connecting-ip"], +}); + app.register(fastifySecureSession, { key: Buffer.from(config.jwt, "hex"), }); -- cgit v1.2.3