aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-03-05 15:28:48 -0800
committerAdam Soltys <[email protected]>2024-03-05 15:28:48 -0800
commit2967b5994469ec83faba99135b696e4367cab67a (patch)
tree869d852efa19227c24b04bf6a4f45d54d4e11b7b
parentc1641e80d3dc113e4adbc48c1bc8e54a5fd68f7c (diff)
downloadcoinos-server-2967b5994469ec83faba99135b696e4367cab67a.tar.gz
coinos-server-2967b5994469ec83faba99135b696e4367cab67a.zip
rate limiting
-rwxr-xr-xbun.lockbbin209835 -> 210299 bytes
-rw-r--r--lib/app.js6
-rw-r--r--package.json1
3 files changed, 7 insertions, 0 deletions
diff --git a/bun.lockb b/bun.lockb
index 684b1a8f..2a0f18f5 100755
--- a/bun.lockb
+++ b/bun.lockb
Binary files differ
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"),
});
diff --git a/package.json b/package.json
index 4433aedb..c30aac0a 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,7 @@
"@fastify/cors": "^8.3.0",
"@fastify/multipart": "^8.0.0",
"@fastify/passport": "^2.4.0",
+ "@fastify/rate-limit": "^9.1.0",
"@fastify/secure-session": "^5.2.0",
"@fastify/static": "^6.5.0",
"@fastify/websocket": "^7.2.0",