import type { StandardSchemaV1 } from "../config/mod.ts"; /** * @unstable * @group Validation * * Get and parse well-known request bodies based on the Content-Type header supplied * * ```js * * // Parse a application/x-www-form-urlencoded * // or multipart/form-data request * const formData = await getRequestBody( * new Request('http://localhost:8000', { body: new FormData() }) * ) * * // Parse an application/json request * const json = await getRequestBody( * new Request('http://localhost:8000', { * body: JSON.stringify({ hello: 'world' }), * headers: { 'Content-Type': 'application/json' }, * }) * ) * ``` */ export declare function getRequestBody(request: Request): Promise; /** * @unstable * @group Validation * * Validate the body of a request against a [StandardSchema](https://standardschema.dev/) or `Structure`. * This will throw nice {@link HTTPError} errors that are caught by gruber and sent along to the user. * * ```js * const struct = Structure.object({ name: Structure.string() }) * * const body1 = await assertRequestBody(struct, new Request('…')) * ``` * * > **NOTE** — you need to await the function when passing a `Request` * * or from a JavaScript value: * * ```js * const body2 = assertRequestBody(struct, { … }) * const body3 = assertRequestBody(struct, new FormData(…)) * const body3 = assertRequestBody(struct, new URLSearchParams(…)) * ``` * * you can use any StandardSchema library with this: * * ```js * import { z } from 'zod' * * const body4 = assertRequestBody( * z.object({ name: z.string() }), * { name: "Geoff Testington" } * ) * ``` */ export declare function assertRequestBody(schema: T, input: Request): Promise>; export declare function assertRequestBody(schema: T, input: unknown): StandardSchemaV1.InferOutput; //# sourceMappingURL=request-body.d.ts.map