export class HttpError extends Error { status: number; code: string; details?: unknown; constructor( status: number, code: string, message: string, details?: unknown, ) { super(message); this.status = status; this.code = code; this.details = details; } } export function jsonResponse( body: unknown, status = 200, headers: HeadersInit = {}, ) { return new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json; charset=utf-8", ...headers, }, }); }