MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / readJsonBody

Function readJsonBody

apps/cloud/src/auth/workos.node.test.ts:107–114  ·  view source on GitHub ↗
(request: IncomingMessage)

Source from the content-addressed store, hash-verified

105const decodeJsonBody = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Unknown));
106
107const readJsonBody = async (request: IncomingMessage): Promise<unknown> => {
108 const chunks: Buffer[] = [];
109 for await (const chunk of request) {
110 chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
111 }
112 const body = Buffer.concat(chunks).toString("utf8");
113 return body ? decodeJsonBody(body) : null;
114};
115
116const writeJson = (response: ServerResponse, status: number, body: unknown): void => {
117 response.writeHead(status, { "content-type": "application/json" });

Callers 1

withWorkOSStubFunction · 0.85

Calls 2

pushMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected