/** * Health Routes - Server health check */ import { Hono } from 'hono'; import { cacheService } from '../services/cacheService'; const health = new Hono(); /** * GET /api/health * Basic health check */ health.get('/', (c) => { return c.json({ status: 'ok', timestamp: new Date().toISOString(), uptime: process.uptime(), }); }); /** * GET /api/health/ready * Readiness check (includes cache connection) */ health.get('/ready', async (c) => { const checks: Record = { server: true, cache: false, }; // Check cache connection try { await cacheService.get('health-check'); checks.cache = true; } catch { checks.cache = false; } const allHealthy = Object.values(checks).every(Boolean); return c.json( { status: allHealthy ? 'ready' : 'degraded', checks, timestamp: new Date().toISOString(), }, allHealthy ? 200 : 503 ); }); /** * GET /api/health/live * Liveness check (just confirms server is running) */ health.get('/live', (c) => { return c.json({ status: 'alive', timestamp: new Date().toISOString(), }); }); export default health;