From 0f342bdadf499461e486ca1fca44db7ea9934245 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Fri, 17 Apr 2026 15:07:22 +0200 Subject: [PATCH] feat(api): add /api/health endpoint Co-Authored-By: Claude Opus 4.7 (1M context) --- src/routes/api/health/+server.ts | 19 +++++++++++++++++++ 1 file changed, 19 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..370b4c3 --- /dev/null +++ b/src/routes/api/health/+server.ts @@ -0,0 +1,19 @@ +import type { RequestHandler } from './$types'; +import { getDb } from '$lib/server/db'; +import { json } from '@sveltejs/kit'; + +export const GET: RequestHandler = async () => { + let dbOk = false; + try { + const db = getDb(); + db.prepare('SELECT 1').get(); + dbOk = true; + } catch { + dbOk = false; + } + const status = dbOk ? 200 : 503; + return json( + { db: dbOk ? 'ok' : 'error', searxng: 'unchecked', version: '0.1.0' }, + { status } + ); +};