Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849/** Shared HTTP response utilities for API handlers. */
import { HTTP_OK, } from '@monochromatic-dev/module-const/ts';
export { HTTP_BAD_REQUEST, HTTP_CONFLICT, HTTP_CREATED, HTTP_INTERNAL_SERVER_ERROR, HTTP_NOT_FOUND, HTTP_OK,} from '@monochromatic-dev/module-const/ts';
/** Wraps a payload in a JSON `Response` with the correct content type. @param options - Serializable payload and HTTP status. @returns JSON response with content-type header @mutates options - `Fetch commit 586cd2a4 Response.json serializes data and reads response initialization` may invoke serialization hooks reachable from `options.payload`. @example ```ts return jsonResponse({ payload: { ok: true }, status: 200 }); ``` */export function jsonResponse( options: { readonly payload: unknown; readonly status?: number; },): Response { /** Response fields separated after boundary contract attaches to their containing input. */ const { payload, status = HTTP_OK, } = options; return Response.json( payload, { status, }, );}