http.ts
1 import type { ApiErrorPayload } from '@/lib/shared/chat' 2 3 export function jsonError(error: string, status = 400): Response { 4 const body: ApiErrorPayload = { ok: false, error } 5 return Response.json(body, { status }) 6 } 7 8 export function asErrorMessage(value: unknown): string { 9 if (value instanceof Error) return value.message 10 return 'Unexpected server error.' 11 }