From 57326d77e766674fd86969927bfe1da3c1077a2b Mon Sep 17 00:00:00 2001 From: Chandler Copeland Date: Fri, 3 Apr 2026 16:53:42 -0600 Subject: [PATCH] feat(17-01): add GET /api/health endpoint with DB connectivity check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- teressa-copeland-homes/src/app/api/health/route.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 teressa-copeland-homes/src/app/api/health/route.ts diff --git a/teressa-copeland-homes/src/app/api/health/route.ts b/teressa-copeland-homes/src/app/api/health/route.ts new file mode 100644 index 0000000..b781ac6 --- /dev/null +++ b/teressa-copeland-homes/src/app/api/health/route.ts @@ -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 }); + } +}