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:
12
teressa-copeland-homes/src/app/api/health/route.ts
Normal file
12
teressa-copeland-homes/src/app/api/health/route.ts
Normal 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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user