[taskboard] add completion sync APIs
This commit is contained in:
30
app/api/tasks/[id]/callback/route.ts
Normal file
30
app/api/tasks/[id]/callback/route.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { applyTaskCallback } from "@/lib/tasks";
|
||||
|
||||
export async function POST(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> },
|
||||
) {
|
||||
const { id } = await params;
|
||||
const numericId = Number(id);
|
||||
if (!Number.isInteger(numericId) || numericId <= 0) {
|
||||
return NextResponse.json({ error: "invalid_task_id" }, { status: 400 });
|
||||
}
|
||||
|
||||
const payload = (await request.json()) as {
|
||||
status?: "Backlog" | "Todo" | "In Progress" | "Review" | "Done";
|
||||
dispatch_state?: "planned" | "assigned" | "dispatched" | "acknowledged" | "completed" | "failed";
|
||||
summary?: string | null;
|
||||
detail?: string | null;
|
||||
completed_by?: string | null;
|
||||
last_error?: string | null;
|
||||
};
|
||||
|
||||
const updated = await applyTaskCallback(numericId, payload);
|
||||
if (!updated) {
|
||||
return NextResponse.json({ error: "task_not_found" }, { status: 404 });
|
||||
}
|
||||
|
||||
return NextResponse.json(updated);
|
||||
}
|
||||
Reference in New Issue
Block a user