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

Function api

telemetry-dashboard/public/app.js:42–64  ·  view source on GitHub ↗
(path, { retry = true } = {})

Source from the content-addressed store, hash-verified

40 * retry: D1 sheds queued queries under load and the second ask usually lands,
41 * while a real failure still reaches the panel a moment later. */
42export async function api(path, { retry = true } = {}) {
43 let response;
44 try {
45 response = await fetch(path, { headers: { accept: 'application/json' } });
46 } catch (err) {
47 if (!retry) throw err;
48 await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
49 return api(path, { retry: false });
50 }
51 if (response.status === 401) {
52 window.location.href = `/login?next=${encodeURIComponent(window.location.pathname)}`;
53 throw new Error('session expired');
54 }
55 if (response.status >= 500 && retry) {
56 await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
57 return api(path, { retry: false });
58 }
59 if (!response.ok) {
60 const detail = await response.json().catch(() => null);
61 throw new Error(detail?.error ?? `responded ${response.status}`);
62 }
63 return response.json();
64}
65
66// ---------------------------------------------------------------------------
67// Days

Callers 2

refreshMetaFunction · 0.70
requestFunction · 0.70

Calls 2

jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected