feat: establish NekoNest Cloud control and relay
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user