feat: add /api/health endpoint for deployment health checks
This commit is contained in:
@@ -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 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user