import { deleteChecklistItem, updateChecklistItem } from '@/lib/delegation.js';

export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';

export async function PATCH(req, { params }) {
  const { itemId } = await params;
  const body = await req.json().catch(() => ({}));
  try {
    return Response.json({ item: updateChecklistItem(itemId, body) });
  } catch (err) {
    return new Response(String(err?.message || err), { status: 400 });
  }
}

export async function DELETE(_req, { params }) {
  const { itemId } = await params;
  return Response.json(deleteChecklistItem(itemId));
}
