Files
electric-cherry/src/routes/api/servers/[name]/+server.ts
T
josh cfed584614 feat: add provisioning lifecycle actions
Rename Deployments to Provisioning with compatible redirects and APIs. Add durable Start, Restart, Stop, and Rebuild operations alongside Create and Destroy; rebuild wipes the instance and recreates it in the same slot and port.

Add lifecycle, migration, recovery, and Komodo command tests. Type checks and production build pass; the full suite retains a telemetry assertion failure reproduced on the unchanged branch.

Refs #39
2026-09-27 14:20:04 -04:00

18 lines
846 B
TypeScript

import { kick } from '$lib/server/pipeline/worker.js';
import { json } from '@sveltejs/kit';
import { destroyServer } from '$lib/server/fleet/create.js';
export async function DELETE({ params }: { params: { name: string } }) {
const name = params.name;
if (!name) {
return json({ ok: false, error: 'server name required', kind: 'bad-request' }, { status: 400 });
}
const result = await destroyServer(name);
if (!result.ok) {
const status = result.kind === 'not-found' ? 404 : result.kind === 'conflict' ? 409 : 500;
return json({ ok: false, error: result.message, kind: result.kind, warnings: result.warnings }, { status });
}
void kick().catch((err) => console.error('[destroy] worker kick failed:', err));
return json({ ok: true, deploymentId: result.deploymentId }, { status: 202 });
}