From 92683e204700ee1ec324280300454d7da64ba718 Mon Sep 17 00:00:00 2001 From: Giancarmine Salucci Date: Wed, 8 Jul 2026 00:58:06 +0200 Subject: [PATCH] feat: add /api/health endpoint for deployment health checks --- src/routes/api/health/+server.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/routes/api/health/+server.ts diff --git a/src/routes/api/health/+server.ts b/src/routes/api/health/+server.ts new file mode 100644 index 0000000..d509ab8 --- /dev/null +++ b/src/routes/api/health/+server.ts @@ -0,0 +1,18 @@ +import { json } from '@sveltejs/kit'; +import { getJob } from '$lib/server/db.js'; + +export async function GET() { + try { + // Real DB query: check if we can fetch a job. + // If no jobs exist, this succeeds with null (schema exists and is reachable). + // If schema doesn't exist or DB is down, this throws. + getJob('no-such-job'); + + return json({ status: 'ok' }, { status: 200 }); + } catch (err) { + return json( + { status: 'error', message: String(err) }, + { status: 500 } + ); + } +}