From 3b3b76548b6cd097df796e9b00288e9919827ef0 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Thu, 1 Feb 2024 20:49:07 -0500 Subject: [PATCH] add etag --- backend/package-lock.json | 9 +++++++++ backend/package.json | 1 + backend/src/server/app.ts | 3 +++ 3 files changed, 13 insertions(+) diff --git a/backend/package-lock.json b/backend/package-lock.json index d1d12ad2e..0b471d2a8 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -13,6 +13,7 @@ "@casl/ability": "^6.5.0", "@fastify/cookie": "^9.2.0", "@fastify/cors": "^8.4.1", + "@fastify/etag": "^5.1.0", "@fastify/formbody": "^7.4.0", "@fastify/helmet": "^11.1.1", "@fastify/passport": "^2.4.0", @@ -1671,6 +1672,14 @@ "resolved": "https://registry.npmjs.org/@fastify/error/-/error-3.4.1.tgz", "integrity": "sha512-wWSvph+29GR783IhmvdwWnN4bUxTD01Vm5Xad4i7i1VuAOItLvbPAb69sb0IQ2N57yprvhNIwAP5B6xfKTmjmQ==" }, + "node_modules/@fastify/etag": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@fastify/etag/-/etag-5.1.0.tgz", + "integrity": "sha512-j/huE8baxgF22idzY35a579b6uP+9ykE9Jt02xY4ZApELNr2KGZmQOKTQsZS94TfKMLfPHwkoM8FfZRq8OZDXg==", + "dependencies": { + "fastify-plugin": "^4.0.0" + } + }, "node_modules/@fastify/fast-json-stringify-compiler": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@fastify/fast-json-stringify-compiler/-/fast-json-stringify-compiler-4.3.0.tgz", diff --git a/backend/package.json b/backend/package.json index 39aed4e34..7562612ec 100644 --- a/backend/package.json +++ b/backend/package.json @@ -67,6 +67,7 @@ "@casl/ability": "^6.5.0", "@fastify/cookie": "^9.2.0", "@fastify/cors": "^8.4.1", + "@fastify/etag": "^5.1.0", "@fastify/formbody": "^7.4.0", "@fastify/helmet": "^11.1.1", "@fastify/passport": "^2.4.0", diff --git a/backend/src/server/app.ts b/backend/src/server/app.ts index c8eb0d28f..15f7bcfa8 100644 --- a/backend/src/server/app.ts +++ b/backend/src/server/app.ts @@ -5,6 +5,7 @@ import type { FastifyCookieOptions } from "@fastify/cookie"; import cookie from "@fastify/cookie"; import type { FastifyCorsOptions } from "@fastify/cors"; import cors from "@fastify/cors"; +import fastifyEtag from "@fastify/etag"; import fastifyFormBody from "@fastify/formbody"; import helmet from "@fastify/helmet"; import type { FastifyRateLimitOptions } from "@fastify/rate-limit"; @@ -50,6 +51,8 @@ export const main = async ({ db, smtp, logger, queue }: TMain) => { secret: appCfg.COOKIE_SECRET_SIGN_KEY }); + await server.register(fastifyEtag); + await server.register(cors, { credentials: true, origin: appCfg.SITE_URL || true