From dd45f3cd391bb0e713e7393636aa6a1f32d8b073 Mon Sep 17 00:00:00 2001 From: RinYato Date: Fri, 20 Sep 2024 22:32:39 +0700 Subject: [PATCH] feat: improve header --- apps/api/src/index.ts | 4 ++++ apps/api/src/setup/header.ts | 8 ++++++++ apps/web/biome.json | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 apps/api/src/setup/header.ts diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 5f69d94..7348ce7 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -13,6 +13,7 @@ import type { AppEnv } from "@/setup/context"; import { TransactionTasker } from "@/task/transaction"; import { registerGlobalErrorHandler } from "./setup/error"; import { registerLogger } from "./setup/logger"; +import { registerHeaderMiddleware } from "./setup/header"; const app = new OpenAPIHono(); @@ -37,6 +38,9 @@ registerAuthMiddleware(app); // Register Logger registerLogger(app); +// Register headers middleware +registerHeaderMiddleware(app); + // Register modules app.route("/", Modules); diff --git a/apps/api/src/setup/header.ts b/apps/api/src/setup/header.ts new file mode 100644 index 0000000..9239278 --- /dev/null +++ b/apps/api/src/setup/header.ts @@ -0,0 +1,8 @@ +import { csrf } from "hono/csrf"; +import type { App } from "./context"; +import { requestId } from "hono/request-id"; +import { secureHeaders } from "hono/secure-headers"; + +export function registerHeaderMiddleware(app: App) { + app.use(csrf(), requestId(), secureHeaders()); +} diff --git a/apps/web/biome.json b/apps/web/biome.json index 963aba0..adbbc07 100644 --- a/apps/web/biome.json +++ b/apps/web/biome.json @@ -1,7 +1,7 @@ { "$schema": "https://biomejs.dev/schemas/1.6.3/schema.json", "files": { - "ignore": [".next", "public", "./src/route-tree.gen.ts"] + "ignore": ["dist", "public", "./src/route.gen.ts"] }, "extends": ["../../biome.json"], "linter": {