feat: establish NekoNest Cloud control and relay
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { authenticateRelayNode } from "@/db/relay-control-plane";
|
||||
import { advanceRelayPurge } from "@/db/relay-purges";
|
||||
import { apiError, readJsonMutation } from "../../../../respond";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const principal = await authenticateRelayNode(request);
|
||||
const payload = await readJsonMutation<{
|
||||
purge_id?: string;
|
||||
action?: "completed" | "failed";
|
||||
evidence_sha256?: string;
|
||||
error_code?: string;
|
||||
}>(request);
|
||||
if (!payload.action) {
|
||||
return Response.json(
|
||||
{ error_code: "invalid_relay_purge", message: "租户删除动作无效", retryable: false },
|
||||
{ status: 400, headers: { "cache-control": "no-store" } },
|
||||
);
|
||||
}
|
||||
const purge = await advanceRelayPurge({
|
||||
principal,
|
||||
purgeId: payload.purge_id ?? "",
|
||||
action: payload.action,
|
||||
evidenceSha256: payload.evidence_sha256,
|
||||
errorCode: payload.error_code,
|
||||
});
|
||||
return Response.json(
|
||||
{ purge_id: purge.id, state: purge.state, updated_at: purge.updated_at },
|
||||
{ headers: { "cache-control": "no-store" } },
|
||||
);
|
||||
} catch (error) {
|
||||
return apiError(error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user