Helpers
Each helper takes the routup event as its first argument. All buffered helpers cache their result on event.store, so subsequent calls within the same request return the cached value.
readRequestBody
Returns the parsed body (JSON or URL-encoded). Pass a key to extract a single field.
declare function readRequestBody(
event: IRoutupEvent,
): Promise<Record<string, any>>;
declare function readRequestBody(
event: IRoutupEvent,
key: string,
): Promise<any | undefined>;const body = await readRequestBody(event);
const email = await readRequestBody(event, 'email');readRequestBodyText
Returns the body decoded as a string.
declare function readRequestBodyText(
event: IRoutupEvent,
options?: TextOptions,
): Promise<string>;Requires body({ text: true }) (or a text config block) on the router.
readRequestBodyBytes
Returns the body as a Uint8Array.
declare function readRequestBodyBytes(
event: IRoutupEvent,
options?: RawOptions,
): Promise<Uint8Array>;Requires body({ raw: true }).
readRequestBodyArrayBuffer
Returns the body as an ArrayBuffer.
declare function readRequestBodyArrayBuffer(
event: IRoutupEvent,
options?: BaseOptions,
): Promise<ArrayBuffer>;readRequestBodyBlob
Returns the body as a Blob — the Blob's type reflects the request Content-Type.
declare function readRequestBodyBlob(
event: IRoutupEvent,
options?: BaseOptions,
): Promise<Blob>;readRequestBodyStream
Returns the body as a ReadableStream, with transparent decoding when the Content-Encoding header indicates gzip, deflate, or br. Does not buffer or cache — useful for piping large bodies straight to disk, S3, etc.
declare function readRequestBodyStream(
event: IRoutupEvent,
options?: BaseOptions,
): ReadableStream | null;Returns null when the request has no body.