Skip to content

Function: validateAndParseJsonBody() ​

validateAndParseJsonBody(request): Promise<Record<string, unknown>>

Defined in: index.ts:121

Validates a request body with JSON content type and parses it. Combines ensureJsonContentType and parseJsonBody.

Parameters ​

request ​

Request

The HTTP request to validate and parse

Returns ​

Promise<Record<string, unknown>>

The parsed JSON object

Throws ​

InvalidContentTypeError if Content-Type is not application/json

Throws ​

InvalidJsonBodyError if the body is not valid JSON or not an object

Example ​

typescript
const body = await validateAndParseJsonBody(request);