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

Function sendText

src/ui-server/static.ts:105–113  ·  view source on GitHub ↗
(res: ServerResponse, status: number, message: string, method: string)

Source from the content-addressed store, hash-verified

103
104/** Send a plain-text status response (the error path for a browser or curl). */
105export function sendText(res: ServerResponse, status: number, message: string, method: string): void {
106 const body = Buffer.from(message.endsWith('\n') ? message : `${message}\n`, 'utf-8');
107 res.writeHead(status, {
108 'Content-Type': 'text/plain; charset=utf-8',
109 'Content-Length': String(body.byteLength),
110 'Cache-Control': 'no-store',
111 });
112 res.end(method === 'HEAD' ? undefined : body);
113}
114
115/** Send a JSON response. Used for `/api/*`, which must never get HTML back. */
116export function sendJson(res: ServerResponse, status: number, payload: unknown, method: string): void {

Callers 2

handleRequestFunction · 0.90
sendFileFunction · 0.85

Calls 1

fromMethod · 0.80

Tested by

no test coverage detected