feat(api): add /api/health endpoint
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
19
src/routes/api/health/+server.ts
Normal file
19
src/routes/api/health/+server.ts
Normal file
@@ -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 }
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user