feat(web): /api/box status, lifecycle, tree, file, terminal-token routes
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
import { proxyBox, withBox } from '@/lib/agent-worker-proxy';
|
||||||
|
|
||||||
|
export const GET = async (request: Request) =>
|
||||||
|
await withBox(async (username) => {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
return await proxyBox(
|
||||||
|
username,
|
||||||
|
'file',
|
||||||
|
{ method: 'GET' },
|
||||||
|
new URLSearchParams({ path: url.searchParams.get('path') ?? '' }),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export const PUT = async (request: Request) =>
|
||||||
|
await withBox(
|
||||||
|
async (username) =>
|
||||||
|
await proxyBox(username, 'file', {
|
||||||
|
method: 'PUT',
|
||||||
|
body: await request.text(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { proxyBox, withBox } from '@/lib/agent-worker-proxy';
|
||||||
|
|
||||||
|
export const POST = async (request: Request) =>
|
||||||
|
await withBox(
|
||||||
|
async (username) =>
|
||||||
|
await proxyBox(username, 'lifecycle', {
|
||||||
|
method: 'POST',
|
||||||
|
body: await request.text(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { proxyBox, withBox } from '@/lib/agent-worker-proxy';
|
||||||
|
|
||||||
|
export const GET = async () =>
|
||||||
|
await withBox(
|
||||||
|
async (username) => await proxyBox(username, 'status', { method: 'GET' }),
|
||||||
|
);
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
import { mintBoxTerminalToken, resolveBoxUsername } from '@/lib/agent-worker-proxy';
|
||||||
|
|
||||||
|
export const GET = async () => {
|
||||||
|
const resolved = await resolveBoxUsername();
|
||||||
|
if (!resolved.ok) return resolved.response;
|
||||||
|
const minted = mintBoxTerminalToken(resolved.username);
|
||||||
|
return minted
|
||||||
|
? NextResponse.json(minted)
|
||||||
|
: NextResponse.json(
|
||||||
|
{ error: 'Terminal is not configured on this deployment.' },
|
||||||
|
{ status: 503 },
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { proxyBox, withBox } from '@/lib/agent-worker-proxy';
|
||||||
|
|
||||||
|
export const GET = async () =>
|
||||||
|
await withBox(
|
||||||
|
async (username) => await proxyBox(username, 'tree', { method: 'GET' }),
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user