feat: establish NekoNest Cloud control and relay
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { getCloudViewer } from "@/app/cloud-auth";
|
||||
import { setPublicBeta } from "@/db/repository";
|
||||
import { apiError, readJsonMutation } from "../../respond";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const viewer = await getCloudViewer();
|
||||
if (!viewer) return Response.json({ error: "authentication_required", message: "请先登录" }, { status: 401 });
|
||||
if (!viewer.isAdmin) return Response.json({ error: "forbidden", message: "没有商业后台权限" }, { status: 403 });
|
||||
const payload = await readJsonMutation<{ enabled?: boolean; capacitySlots?: number | null; reason?: string; idempotencyKey?: string }>(request);
|
||||
const beta = await setPublicBeta({ actorId: viewer.userId, enabled: payload.enabled ?? false, capacitySlots: payload.capacitySlots ?? null, reason: payload.reason ?? "", idempotencyKey: payload.idempotencyKey ?? "" });
|
||||
return Response.json({ beta });
|
||||
} catch (error) { return apiError(error); }
|
||||
}
|
||||
Reference in New Issue
Block a user