Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

1.1 KB
Raw Blame
import { withIntegrationSelection } from "@/lib/infra/connection-service";
import { selectionFrom } from "@/lib/infra/connection-dispatch";
import { NextRequest, NextResponse } from "next/server";
import { requireSession } from "@/lib/auth/require-session";
import { INFRA_PROVIDER_IDS, doctorInfraProvider, isInfraProviderId } from "@/lib/infra";

export async function handlePostInfraDoctor(req: NextRequest): Promise<Response> {
  if (!(await requireSession("owner"))) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  let body: { id?: string; user?: string; connection?: string; cwd?: string } = {};
  try {
    body = await req.json();
  } catch {
    /* empty means all */
  }
  const ids = body.id ? [body.id] : [...INFRA_PROVIDER_IDS];
  if (ids.some((id) => !isInfraProviderId(id)))
    return NextResponse.json({ error: "unknown infrastructure provider" }, { status: 404 });
  const results = await withIntegrationSelection(selectionFrom(body), () =>
    Promise.all(ids.map((id) => doctorInfraProvider(id as (typeof INFRA_PROVIDER_IDS)[number]))),
  );
  return NextResponse.json({ results });
}