feat(17-01): add GET /api/health endpoint with DB connectivity check

- Runs SELECT 1 via Drizzle db client
- Returns { ok: true, db: 'connected' } with status 200 on success
- Returns { ok: false, error: message } with status 503 on DB failure
- No auth check — intentionally public for Docker HEALTHCHECK
This commit is contained in:
Chandler Copeland
2026-04-03 16:53:42 -06:00
parent fa7d6a9636
commit 57326d77e7

View File

@@ -0,0 +1,12 @@
import { db } from '@/lib/db';
import { sql } from 'drizzle-orm';
export async function GET() {
try {
await db.execute(sql`SELECT 1`);
return Response.json({ ok: true, db: 'connected' });
} catch (e) {
const message = e instanceof Error ? e.message : 'Unknown error';
return Response.json({ ok: false, error: message }, { status: 503 });
}
}