refactor: keep imported project understanding sync automatic

This commit is contained in:
kris
2026-04-04 08:43:53 +08:00
parent 432cf97541
commit cf57b5058f
9 changed files with 25 additions and 502 deletions

View File

@@ -1,30 +0,0 @@
import { NextRequest, NextResponse } from "next/server";
import { authorizeDeviceSessionRequest } from "@/lib/boss-device-auth";
import { syncDeviceProjectUnderstanding } from "@/lib/boss-data";
export async function POST(
request: NextRequest,
context: { params: Promise<{ deviceId: string }> },
) {
const { deviceId } = await context.params;
const auth = await authorizeDeviceSessionRequest(request, deviceId);
if (!auth.ok) {
return NextResponse.json(
{ ok: false, message: auth.status === 404 ? "DEVICE_NOT_FOUND" : "UNAUTHORIZED" },
{ status: auth.status },
);
}
try {
const result = await syncDeviceProjectUnderstanding({
deviceId,
requestedByAccount: auth.session.account,
});
return NextResponse.json(result);
} catch (error) {
return NextResponse.json(
{ ok: false, message: error instanceof Error ? error.message : "UNKNOWN_ERROR" },
{ status: 400 },
);
}
}