diff options
| author | Adam Soltys <[email protected]> | 2024-03-05 15:28:48 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-03-05 15:28:48 -0800 |
| commit | 2967b5994469ec83faba99135b696e4367cab67a (patch) | |
| tree | 869d852efa19227c24b04bf6a4f45d54d4e11b7b | |
| parent | c1641e80d3dc113e4adbc48c1bc8e54a5fd68f7c (diff) | |
| download | coinos-server-2967b5994469ec83faba99135b696e4367cab67a.tar.gz coinos-server-2967b5994469ec83faba99135b696e4367cab67a.zip | |
rate limiting
| -rwxr-xr-x | bun.lockb | bin | 209835 -> 210299 bytes | |||
| -rw-r--r-- | lib/app.js | 6 | ||||
| -rw-r--r-- | package.json | 1 |
3 files changed, 7 insertions, 0 deletions
| Binary files differ @@ -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", |
