Add multi-server blueprint collections and atomic launches
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { deleteBlueprint } from '$lib/server/fleet/launch-recipes.js';
|
||||
import { deleteBlueprint, updateBlueprint } from '$lib/server/fleet/launch-recipes.js';
|
||||
|
||||
export function DELETE({ params }: { params: { id: string } }) {
|
||||
return deleteBlueprint(params.id) ? json({ ok: true }) : json({ error: 'Blueprint not found.' }, { status: 404 });
|
||||
}
|
||||
|
||||
export async function PUT({ params, request }: { params: { id: string }; request: Request }) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
if (!body || typeof body !== 'object' || Array.isArray(body)) throw new Error('Provide a blueprint name and map selections.');
|
||||
return json({ blueprint: updateBlueprint(params.id, body) });
|
||||
} catch (err) { return json({ error: (err as Error).message }, { status: 400 }); }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { listCollections, queueCollection } from '$lib/server/fleet/collections.js';
|
||||
import { kick } from '$lib/server/pipeline/worker.js';
|
||||
|
||||
export function GET() { return json({ collections: listCollections() }); }
|
||||
|
||||
export async function POST({ request }: { request: Request }) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
if (!body || typeof body !== 'object' || Array.isArray(body)) throw new Error('Provide a collection preview and its server keys.');
|
||||
const result = queueCollection(body);
|
||||
void kick().catch(err => console.error('[collection] worker kick failed:', err));
|
||||
return json(result, { status: 202 });
|
||||
} catch (err) { return json({ error: (err as Error).message }, { status: 400 }); }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { error, json } from '@sveltejs/kit';
|
||||
import { getCollection } from '$lib/server/fleet/collections.js';
|
||||
|
||||
export function GET({ params }: { params: { id: string } }) {
|
||||
const detail = getCollection(params.id);
|
||||
if (!detail) error(404, 'Collection not found.');
|
||||
return json(detail);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { previewCollection } from '$lib/server/fleet/collections.js';
|
||||
|
||||
export async function POST({ request }: { request: Request }) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
return json(previewCollection(body?.blueprintId));
|
||||
} catch (err) { return json({ error: (err as Error).message }, { status: 400 }); }
|
||||
}
|
||||
Reference in New Issue
Block a user