1// GET /api/me: the signed-in account and its machines, or 401.2import { define } from "../../utils.ts";3import { accountOfRequest } from "../../lib/identity.ts";4import { machineRegistry } from "../../lib/mcp.ts";56export const handler = define.handlers({7 async GET(ctx) {8 const id = await accountOfRequest(ctx.req);9 if (!id) return Response.json({ error: "not signed in" }, { status: 401 });10 const store = await machineRegistry();11 const account = store.getAccount(id);12 return Response.json({13 account: { id, name: account?.name ?? null },14 machines: store.machinesOf(id).map((m) => ({15 machine_id: m.machine_id,16 name: m.name,17 first_seen: m.first_seen,18 last_seen: m.last_seen,19 })),20 }, { headers: { "Cache-Control": "no-store" } });21 },22});