26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { backendFetch, readBackendError } from "@/lib/backend";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
export async function GET(_request: NextRequest, context: { params: Promise<{ conversationId: string }> }) {
|
|
const { conversationId } = await context.params;
|
|
const response = await backendFetch(`/v1/conversations/${encodeURIComponent(conversationId)}`);
|
|
if (!response.ok) return NextResponse.json({ error: await readBackendError(response) }, { status: response.status });
|
|
return NextResponse.json(await response.json());
|
|
}
|
|
|
|
export async function PATCH(request: NextRequest, context: { params: Promise<{ conversationId: string }> }) {
|
|
const { conversationId } = await context.params;
|
|
const body = await request.json().catch(() => ({}));
|
|
const response = await backendFetch(`/v1/conversations/${encodeURIComponent(conversationId)}`, {
|
|
method: "PATCH",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
current_task_id: body.currentTaskId || null,
|
|
}),
|
|
});
|
|
if (!response.ok) return NextResponse.json({ error: await readBackendError(response) }, { status: response.status });
|
|
return NextResponse.json(await response.json());
|
|
}
|