Files
Wanjohi 04bb25bf66 feat(api): rooms are GPUs and plans count rooms
A box records the GPU it is pinned to. GET /location lists your own
GPUs and the fleet's by model. POST /box takes { on: own, machineId,
pciId } or { on: fleet, model }; free holds 1 cloud room on entry
models, Pro 3 on any, own rooms are unlimited, and refusals are typed
(room_limit, gpu_needs_pro). The weekend trial and the usage windows no
longer decide anything and GET /billing reports plan and room counts.
Cloud rooms with nothing live for 3 hours are stopped when their host
polls for work.
2026-10-19 21:59:29 +03:00

33 lines
1.1 KiB
TypeScript

import { Actor } from '@nestri/core/actor';
import { Location } from '@nestri/core/box/location';
import { Team } from '@nestri/core/team/index';
import { Hono } from 'hono';
import { describeRoute } from 'hono-openapi';
import { ErrorResponses, notPublic, Result } from '../utils';
/** Where a room can be created. */
export namespace LocationApi {
export const route = new Hono().use(notPublic).get(
'/',
describeRoute({
tags: ['Location'],
summary: 'GPUs a room can go on',
description:
'Your own GPUs, one entry per card your hosts report, and the Nestri GPUs grouped by model. For each model, `available` says whether one is free now, `entry` whether it is an entry model, and `allowed` whether your plan may create a room on it.',
responses: {
200: {
content: { 'application/json': { schema: Result(Location.Info) } },
description: 'Your locations'
},
401: ErrorResponses[401]
}
}),
async (c) => {
const userId = Actor.userID;
const plan = (await Team.personalFor(userId))?.plan ?? 'free';
return c.json({ data: await Location.list({ userId, plan }) });
}
);
}