Files
ProjectE/apps/api/src/routes/health.ts
T
Hermes e4a241b38f T2/Phase 2A: port auth + infrastructure routes to Hono (~8 routes)
- /api/health: DB ping + version + uptime
   - /api/auth/*: NextAuth -> Auth.js standalone (credentials + passkey)
   - /api/domains: full CRUD
   - /api/realtime: SSE with PostgreSQL LISTEN/NOTIFY
   - /mcp: JSON-RPC 2.0 (initialize, tools/list, tools/call, resources/*)

   Parent: t_e1cbd87d -> t_d8654a91 (T1)
2026-08-01 01:25:01 +00:00

28 lines
585 B
TypeScript

import { db, sql } from "@project-e/db";
export async function healthHandler() {
const start = Date.now();
let dbOk = false;
let dbPingMs = 0;
try {
const result = await sql`SELECT 1 AS ok`;
dbOk = true;
dbPingMs = Date.now() - start;
} catch {
dbOk = false;
dbPingMs = -1;
}
return {
status: dbOk ? "ok" : "degraded",
timestamp: new Date().toISOString(),
version: process.env.npm_package_version || "0.1.0",
runtime: "bun",
uptime: process.uptime(),
database: {
connected: dbOk,
ping_ms: dbPingMs,
},
};
}