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

Function apiResponse

telemetry-dashboard/src/index.ts:208–217  ·  view source on GitHub ↗

* The chart endpoints live in src/api.ts and return data, not responses, so this * file stays the single place that decides headers on an authenticated reply. * Everything under `/api/` is behind the same session check as the pages.

(env: Env, url: URL)

Source from the content-addressed store, hash-verified

206 * Everything under `/api/` is behind the same session check as the pages.
207 */
208async function apiResponse(env: Env, url: URL): Promise<Response> {
209 const result = await handleApi(env, url);
210 return json(result.body, {
211 status: result.status,
212 // Chart data is daily-granular, so a few minutes in the browser's private
213 // cache saves D1 a round of identical queries on every panel re-render.
214 // Anything without an explicit lifetime keeps the no-store default.
215 headers: result.cacheControl ? { 'cache-control': result.cacheControl } : undefined,
216 });
217}
218
219/** Gated static assets: the dashboard shell, its JS, its CSS, the chart library. */
220async function serveAsset(env: Env, request: Request): Promise<Response> {

Callers 1

fetchFunction · 0.85

Calls 2

handleApiFunction · 0.90
jsonFunction · 0.70

Tested by

no test coverage detected