MCPcopy Index your code
hub / github.com/cloudflare/vibesdk / parseJSON

Function parseJSON

worker/utils/inputValidator.ts:83–104  ·  view source on GitHub ↗

* Parse JSON body with size limit

(request: Request)

Source from the content-addressed store, hash-verified

81 * Parse JSON body with size limit
82 */
83async function parseJSON(request: Request): Promise<unknown> {
84 const text = await request.text();
85
86 // Check size limit (1MB)
87 if (text.length > 1024 * 1024) {
88 throw new SecurityError(
89 SecurityErrorType.INVALID_INPUT,
90 'Request body too large',
91 413
92 );
93 }
94
95 try {
96 return JSON.parse(text);
97 } catch {
98 throw new SecurityError(
99 SecurityErrorType.INVALID_INPUT,
100 'Invalid JSON',
101 400
102 );
103 }
104}
105
106/**
107 * Parse URL-encoded form data

Callers 1

validateInputFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected