Something went wrong. Try again.
The logic for serving and storing associations between users and apps
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637export function json(data: unknown, status = 200, headers?: HeadersInit): Response { return new Response(JSON.stringify(data), { status, headers: { "content-type": "application/json; charset=utf-8", ...headers, }, });}
export function xrpcError(error: string, message: string, status = 400): Response { return json({ error, message }, status);}
export async function readJson(request: Request): Promise<Record<string, unknown>> { try { const body: unknown = await request.json(); if (typeof body !== "object" || body === null || Array.isArray(body)) { throw new Error("expected object"); } return body as Record<string, unknown>; } catch { throw new XrpcRequestError("InvalidRequest", "expected a JSON object"); }}
export class XrpcRequestError extends Error { error: string; status: number;
constructor(error: string, message: string, status = 400) { super(message); this.error = error; this.status = status; }}