MCPcopy Create free account
hub / github.com/ZToolsCenter/ZTools / sendJson

Method sendJson

src/main/core/httpServer.ts:115–123  ·  view source on GitHub ↗
(res: ServerResponse, statusCode: number, body: ApiResponse)

Source from the content-addressed store, hash-verified

113 }
114
115 private sendJson(res: ServerResponse, statusCode: number, body: ApiResponse): void {
116 res.writeHead(statusCode, {
117 'Content-Type': 'application/json; charset=utf-8',
118 'Access-Control-Allow-Origin': '*',
119 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
120 'Access-Control-Allow-Headers': 'Content-Type, Authorization'
121 })
122 res.end(JSON.stringify(body))
123 }
124
125 private async handleRequest(req: IncomingMessage, res: ServerResponse): Promise<void> {
126 if (req.method === 'OPTIONS') {

Callers 1

handleRequestMethod · 0.95

Calls 1

stringifyMethod · 0.80

Tested by

no test coverage detected