From 63d83e0d7cebf12fce8573f54f828cd4dc2167aa Mon Sep 17 00:00:00 2001 From: "Sven (AAMOS AI)" Date: Tue, 11 Aug 2026 07:37:51 +0700 Subject: [PATCH] =?UTF-8?q?ops(api):=20l=C3=A4gg=20till=20/ops/v1/health?= =?UTF-8?q?=20f=C3=B6r=20EOC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/routes/ops.ts | 5 +++++ apps/api/test/ops.test.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/apps/api/src/routes/ops.ts b/apps/api/src/routes/ops.ts index cd53a40..feab331 100644 --- a/apps/api/src/routes/ops.ts +++ b/apps/api/src/routes/ops.ts @@ -35,6 +35,11 @@ function requireOpsToken(app: FastifyInstance) { export async function opsRoutes(app: FastifyInstance) { const preHandler = [requireOpsToken(app)]; + app.get("/ops/v1/health", { preHandler }, async () => ({ + ok: true, + app: "cibello", + })); + app.get("/ops/v1/summary", { preHandler }, async (_req, reply) => { const [json, ts] = await app.redis.mget(CACHE_KEY, CACHE_TS_KEY); if (!json) { diff --git a/apps/api/test/ops.test.ts b/apps/api/test/ops.test.ts index 7feaf72..9045260 100644 --- a/apps/api/test/ops.test.ts +++ b/apps/api/test/ops.test.ts @@ -24,6 +24,36 @@ const planPrices = { large_household: 19900, }; +describe("/ops/v1/health", () => { + let app: Awaited>; + + beforeAll(async () => { + app = await buildServer(config); + await app.ready(); + }); + + afterAll(async () => { + await app.close(); + }); + + it("avvisar anrop utan token", async () => { + const res = await app.inject({ method: "GET", url: "/ops/v1/health" }); + expect(res.statusCode).toBe(401); + }); + + it("returnerar ok med app-namn vid giltig token", async () => { + const res = await app.inject({ + method: "GET", + url: "/ops/v1/health", + headers: { authorization: `Bearer ${config.OPS_TOKEN}` }, + }); + expect(res.statusCode).toBe(200); + const body = JSON.parse(res.body) as { ok: boolean; app: string }; + expect(body.ok).toBe(true); + expect(body.app).toBe("cibello"); + }); +}); + describe("/ops/v1/summary", () => { let app: Awaited>;