import { authenticateRelayNode, resolveDeviceRouteForRelay, } from "@/db/relay-control-plane"; import { apiError, readJsonMutation } from "../../../respond"; export async function POST(request: Request) { try { const principal = await authenticateRelayNode(request); const payload = await readJsonMutation<{ device_id?: string; token_hash?: string }>(request); return Response.json( await resolveDeviceRouteForRelay({ principal, deviceId: payload.device_id ?? "", tokenHash: payload.token_hash ?? "", }), { headers: { "cache-control": "no-store" } }, ); } catch (error) { return apiError(error); } }