import { apiFetch, jsonResponse } from '../../../_lib/api'; export const dynamic = 'force-dynamic'; export async function PATCH( req: Request, { params }: { params: Promise<{ id: string }> }, ): Promise { const { id } = await params; const body = await req.text(); const res = await apiFetch(`/routes/${id}`, { method: 'PATCH', body }); const text = await res.text(); let payload: unknown = text; try { payload = JSON.parse(text); } catch { /* keep as text */ } return jsonResponse(payload, res.status); } export async function DELETE( _req: Request, { params }: { params: Promise<{ id: string }> }, ): Promise { const { id } = await params; const res = await apiFetch(`/routes/${id}`, { method: 'DELETE' }); if (res.status === 204) return new Response(null, { status: 204 }); const body = await res.text(); return new Response(body, { status: res.status, headers: { 'Content-Type': 'application/json' } }); }