MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / health

Function health

telemetry-dashboard/src/api.ts:766–785  ·  view source on GitHub ↗
(env: Env)

Source from the content-addressed store, hash-verified

764// ---------------------------------------------------------------------------
765
766async function health(env: Env): Promise<ApiResult> {
767 try {
768 const batch = await env.DB.batch<{ day: string | null }>([
769 env.DB.prepare('SELECT max(day) AS day FROM events'),
770 env.DB.prepare('SELECT max(day) AS day FROM daily_machines'),
771 ]);
772 return {
773 body: {
774 ok: true,
775 database: {
776 latest_event_day: batch[0]?.results[0]?.day ?? null,
777 latest_rollup_day: batch[1]?.results[0]?.day ?? null,
778 },
779 },
780 };
781 } catch (err) {
782 console.error(JSON.stringify({ msg: 'health query failed', err: String(err) }));
783 return { body: { ok: false, error: 'database unavailable' }, status: 503 };
784 }
785}
786
787// ---------------------------------------------------------------------------
788// Router

Callers 1

handleApiFunction · 0.85

Calls 2

errorMethod · 0.80
prepareMethod · 0.65

Tested by

no test coverage detected