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 } + ); + } +}