[taskboard] add dispatch control plane
This commit is contained in:
21
app/api/tasks/[id]/dispatch/route.ts
Normal file
21
app/api/tasks/[id]/dispatch/route.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { dispatchTask } from "@/lib/dispatch";
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
try {
|
||||
return NextResponse.json(await dispatchTask(numericId));
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
return NextResponse.json({ error: "dispatch_failed", detail: message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user