MCPcopy Create free account
hub / github.com/callstack/agent-device / readRestJsonBody

Function readRestJsonBody

src/daemon/upload-http.ts:230–246  ·  view source on GitHub ↗
(
  req: http.IncomingMessage,
  maxBodyBytes: number,
)

Source from the content-addressed store, hash-verified

228}
229
230async function readRestJsonBody(
231 req: http.IncomingMessage,
232 maxBodyBytes: number,
233): Promise<Record<string, unknown>> {
234 const raw = (
235 await readNodeHttpRequestBody(req, maxBodyBytes, 'Request body is too large.')
236 ).toString('utf8');
237 try {
238 const parsed = JSON.parse(raw) as unknown;
239 if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
240 throw new Error('expected object');
241 }
242 return parsed as Record<string, unknown>;
243 } catch (error) {
244 throw new AppError('INVALID_ARGS', 'Invalid JSON request body', {}, error);
245 }
246}
247
248function readUploadPreflightBody(record: Record<string, unknown>): UploadPreflightBody {
249 return {

Callers 2

handleUploadPreflightFunction · 0.85
handleUploadFinalizeFunction · 0.85

Calls 2

readNodeHttpRequestBodyFunction · 0.90
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…