import { addTaskComment, listTaskComments } from '@/lib/delegation.js';

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

export async function GET(_req, { params }) {
  const { id } = await params;
  return Response.json({ comments: listTaskComments(id) });
}

export async function POST(req, { params }) {
  const { id } = await params;
  const body = await req.json().catch(() => ({}));
  return Response.json({ comment: addTaskComment(id, body) }, { status: 201 });
}
