mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +03:00
Part 3 of CLIProxyAPI integration (#902). Depends on PR1 + PR2. - releaseChecker.ts: GitHub releases API with 5min cache - binaryManager.ts: download, SHA256 verify, install, symlink, rollback - processManager.ts: spawn, graceful stop (SIGTERM→SIGKILL with interval cleanup), restart - healthMonitor.ts: periodic /v1/models health checks - index.ts: orchestrator (install/start/stop/restart/checkUpdates/pin/rollback) - 6 API routes under /api/version-manager/ with Zod validation - CliproxyapiToolCard: CLI Tools page card - Docker: cliproxyapi profile with sidecar service + healthcheck - 78 unit tests across 5 test files
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
"use server";
|
|
|
|
import { NextResponse } from "next/server";
|
|
import { startTool } from "@/lib/versionManager";
|
|
import { versionManagerToolSchema } from "@/shared/validation/schemas";
|
|
import { isValidationFailure, validateBody } from "@/shared/validation/helpers";
|
|
|
|
export async function POST(request: Request) {
|
|
let rawBody;
|
|
try {
|
|
rawBody = await request.json();
|
|
} catch {
|
|
return NextResponse.json({ error: "Invalid JSON body" }, { status: 400 });
|
|
}
|
|
|
|
const validation = validateBody(versionManagerToolSchema, rawBody);
|
|
if (isValidationFailure(validation)) {
|
|
return NextResponse.json({ error: validation.error }, { status: 400 });
|
|
}
|
|
|
|
try {
|
|
const { tool } = validation.data;
|
|
const result = await startTool(tool);
|
|
return NextResponse.json({ success: true, ...result });
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : "Failed to start";
|
|
console.error("[version-manager] start error:", message);
|
|
return NextResponse.json({ error: message }, { status: 500 });
|
|
}
|
|
}
|