import type { DecisionsPayload, HealthPayload, StatusPayload } from './types' async function getJson(path: string): Promise { const resp = await fetch(path) if (!resp.ok) { throw new Error(`API returned ${String(resp.status)} ${resp.statusText}`) } return (await resp.json()) as T } export function fetchStatus(): Promise { return getJson('/api/status') } export function fetchDecisions(limit: number): Promise { return getJson(`/api/decisions?limit=${String(limit)}`) } export function fetchHealth(): Promise { return getJson('/api/health') }