MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / writeJson

Function writeJson

packages/playground/vite.plugin.server.ts:37–45  ·  view source on GitHub ↗
(res: ServerResponse, status: number, statusMessage: string, body: unknown)

Source from the content-addressed store, hash-verified

35}
36
37function writeJson(res: ServerResponse, status: number, statusMessage: string, body: unknown): void {
38 const json = Buffer.from(JSON.stringify(body), 'utf-8');
39 res.writeHead(status, statusMessage, {
40 'content-type': 'application/json',
41 'content-length': json.length
42 });
43 res.write(json);
44 res.end();
45}
46
47function writeError(res: ServerResponse, status: number, statusMessage: string, e?: Error): void {
48 writeJson(res, status, statusMessage, e ? { message: e.message, stack: e.stack } : { message: statusMessage });

Callers 3

writeErrorFunction · 0.85
configureServerFunction · 0.85
handleAcceptFunction · 0.85

Calls 4

fromMethod · 0.80
stringifyMethod · 0.80
writeMethod · 0.65
endMethod · 0.45

Tested by

no test coverage detected