From f007c59764fcbfe46698bb2f99e7eb9a4c03ca54 Mon Sep 17 00:00:00 2001 From: potts99 Date: Sat, 25 Nov 2023 01:53:11 +0000 Subject: [PATCH] rate limit --- apps/api/package.json | 3 +- apps/api/src/main.ts | 5 +++ apps/client/pages/portal/[id]/ticket/[id].tsx | 0 yarn.lock | 37 ++++++++++++++----- 4 files changed, 35 insertions(+), 10 deletions(-) delete mode 100644 apps/client/pages/portal/[id]/ticket/[id].tsx diff --git a/apps/api/package.json b/apps/api/package.json index b6be55ad8..41eec030a 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -25,9 +25,10 @@ "dependencies": { "@fastify/cookie": "^9.0.4", "@fastify/cors": "^8.3.0", + "@fastify/rate-limit": "^9.0.0", "@fastify/session": "^10.4.0", "@fastify/swagger": "^8.10.0", - "@prisma/client": "^5.2.0", + "@prisma/client": "5.2.0", "axios": "^1.5.0", "bcrypt": "^5.0.1", "dotenv": "^16.0.0", diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 4510242af..0f22f38c1 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -59,6 +59,11 @@ server.register(require("@fastify/swagger"), { }, }); +server.register(import("@fastify/rate-limit"), { + max: 20, + timeWindow: "1 minute", +}); + // register all routes registerRoutes(server); diff --git a/apps/client/pages/portal/[id]/ticket/[id].tsx b/apps/client/pages/portal/[id]/ticket/[id].tsx deleted file mode 100644 index e69de29bb..000000000 diff --git a/yarn.lock b/yarn.lock index 259b7b852..7f79e6e61 100644 --- a/yarn.lock +++ b/yarn.lock @@ -378,6 +378,15 @@ dependencies: fast-json-stringify "^5.7.0" +"@fastify/rate-limit@^9.0.0": + version "9.0.0" + resolved "https://registry.yarnpkg.com/@fastify/rate-limit/-/rate-limit-9.0.0.tgz#a69389c0bd565346e763abb7fae5993724eaff20" + integrity sha512-Gt5NXYyidUY47yO0QFvwwVwolbpFcq8Y6wSL0iV8v29IdUQVKhE9hcJE5N48LdnhTQDBdLiZDiR7nV4niMfOWw== + dependencies: + "@lukeed/ms" "^2.0.1" + fastify-plugin "^4.0.0" + toad-cache "^3.3.0" + "@fastify/session@^10.4.0": version "10.6.0" resolved "https://registry.yarnpkg.com/@fastify/session/-/session-10.6.0.tgz#fcbcc1d36eb22bb7f03dda6b80aacffa335d89ec" @@ -531,6 +540,11 @@ titleize "2" tlds "^1.230.0" +"@lukeed/ms@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@lukeed/ms/-/ms-2.0.1.tgz#3c2bbc258affd9cc0e0cc7828477383c73afa6ee" + integrity sha512-Xs/4RZltsAL7pkvaNStUQt7netTkyxrS0K+RILcVr3TRMS/ToOg4I6uNfhB9SlGsnWBym4U+EaXq0f0cEMNkHA== + "@mantine/core@^6.0.13": version "6.0.21" resolved "https://registry.yarnpkg.com/@mantine/core/-/core-6.0.21.tgz#6e3a1b8d0f6869518a644d5f5e3d55a5db7e1e51" @@ -767,17 +781,17 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== -"@prisma/client@^5.2.0": - version "5.6.0" - resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.6.0.tgz#1c15932250d5658fe0127e62faf4ecd96a877259" - integrity sha512-mUDefQFa1wWqk4+JhKPYq8BdVoFk9NFMBXUI8jAkBfQTtgx8WPx02U2HB/XbAz3GSUJpeJOKJQtNvaAIDs6sug== +"@prisma/client@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.2.0.tgz#cbfdd440614b38736563a7999f39922fcde0ed50" + integrity sha512-AiTjJwR4J5Rh6Z/9ZKrBBLel3/5DzUNntMohOy7yObVnVoTNVFi2kvpLZlFuKO50d7yDspOtW6XBpiAd0BVXbQ== dependencies: - "@prisma/engines-version" "5.6.0-32.e95e739751f42d8ca026f6b910f5a2dc5adeaeee" + "@prisma/engines-version" "5.2.0-25.2804dc98259d2ea960602aca6b8e7fdc03c1758f" -"@prisma/engines-version@5.6.0-32.e95e739751f42d8ca026f6b910f5a2dc5adeaeee": - version "5.6.0-32.e95e739751f42d8ca026f6b910f5a2dc5adeaeee" - resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-5.6.0-32.e95e739751f42d8ca026f6b910f5a2dc5adeaeee.tgz#57b003ab5e1ea1523b5cdd7f06b24ebcf5c7fd8c" - integrity sha512-UoFgbV1awGL/3wXuUK3GDaX2SolqczeeJ5b4FVec9tzeGbSWJboPSbT0psSrmgYAKiKnkOPFSLlH6+b+IyOwAw== +"@prisma/engines-version@5.2.0-25.2804dc98259d2ea960602aca6b8e7fdc03c1758f": + version "5.2.0-25.2804dc98259d2ea960602aca6b8e7fdc03c1758f" + resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-5.2.0-25.2804dc98259d2ea960602aca6b8e7fdc03c1758f.tgz#11366e7ff031c908debf4983248d40046016de37" + integrity sha512-jsnKT5JIDIE01lAeCj2ghY9IwxkedhKNvxQeoyLs6dr4ZXynetD0vTy7u6wMJt8vVPv8I5DPy/I4CFaoXAgbtg== "@prisma/engines@5.6.0": version "5.6.0" @@ -6850,6 +6864,11 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +toad-cache@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/toad-cache/-/toad-cache-3.3.0.tgz#5b7dc67b36bc8b960567eb77bdf9ac6c26f204a1" + integrity sha512-3oDzcogWGHZdkwrHyvJVpPjA7oNzY6ENOV3PsWJY9XYPZ6INo94Yd47s5may1U+nleBPwDhrRiTPMIvKaa3MQg== + toggle-selection@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"