refactor: keep imported project understanding sync automatic
This commit is contained in:
@@ -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 },
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user