import { NextResponse } from "next/server"; export function jsonOk(payload: T, init?: ResponseInit) { return NextResponse.json(payload, init); } export function jsonError(error: unknown, status = 400) { return NextResponse.json({ error: error instanceof Error ? error.message : String(error) }, { status }); } export async function readJsonBody>(request: Request): Promise { try { return await request.json() as T; } catch { return {} as T; } }