MCPcopy
hub / github.com/callumalpass/tasknotes / sendJSONResponse

Function sendJSONResponse

src/api/httpUtils.ts:59–69  ·  view source on GitHub ↗
(
	res: HTTPResponseLike,
	statusCode: number,
	data: unknown,
	corsOptions?: CORSHeaderOptions
)

Source from the content-addressed store, hash-verified

57}
58
59export function sendJSONResponse(
60 res: HTTPResponseLike,
61 statusCode: number,
62 data: unknown,
63 corsOptions?: CORSHeaderOptions
64): void {
65 res.statusCode = statusCode;
66 res.setHeader("Content-Type", "application/json");
67 setCORSHeaders(res, corsOptions);
68 res.end(JSON.stringify(data));
69}
70
71export function parseJSONBody(req: HTTPRequestLike): Promise<Record<string, unknown>> {
72 return new Promise((resolve, reject) => {

Callers 2

sendResponseMethod · 0.90
sendResponseFunction · 0.90

Calls 3

setCORSHeadersFunction · 0.85
setHeaderMethod · 0.80
endMethod · 0.65

Tested by

no test coverage detected