import Elysia, { t } from "elysia"; import { redis } from "@/services/redis"; import { baseLogger } from "@/utils/logger"; export const healthRoutes = new Elysia().get( "/health", async ({ set, error }) => { const perf = performance.now(); try { await redis.ping(); } catch (e) { baseLogger.error("Redis connection error:", e); console.log("Redis connection error:", e); return error(503, { healthy: false }); } const duration = performance.now() - perf; baseLogger.info(`Service healthy: ${duration.toFixed(2)} ms`); return { healthy: true }; }, { response: { 200: t.Object({ healthy: t.Boolean(), }), 503: t.Object({ healthy: t.Boolean(), }), }, } );