Bound request bodies and artifact uploads (Refs #94)
CI / checks (push) Successful in 4m34s

This commit is contained in:
2026-10-09 16:52:37 -04:00
parent 8fcb8312a3
commit 9eb3aa84c3
44 changed files with 603 additions and 79 deletions
@@ -1,4 +1,5 @@
import { json } from '@sveltejs/kit';
import { jsonBody } from '$lib/server/request-body.js';
import { isHttpError, json } from '@sveltejs/kit';
import { housePartyTargets, queueHouseParty } from '$lib/server/fleet/house-party.js';
import { kick } from '$lib/server/pipeline/worker.js';
@@ -7,7 +8,10 @@ export function GET() {
}
export async function POST({ request }: { request: Request }) {
const body = await request.json().catch(() => null);
const body = await jsonBody(request).catch((cause) => {
if (isHttpError(cause, 413)) throw cause;
return null;
});
if (
!Array.isArray(body?.servers) ||
!body.servers.every((name: unknown) => typeof name === 'string')
@@ -1,9 +1,10 @@
import { json } from '@sveltejs/kit';
import { jsonBody } from '$lib/server/request-body.js';
import { isHttpError, json } from '@sveltejs/kit';
import { previewCreation } from '$lib/server/provisioning/index.js';
export async function POST({ request }: { request: Request }) {
try {
const body = await request.json();
const body = await jsonBody(request);
if (!body || typeof body !== 'object' || Array.isArray(body))
throw new Error('Provide a launch selection.');
if (body.blueprintId !== undefined)
@@ -12,6 +13,7 @@ export async function POST({ request }: { request: Request }) {
);
return json(previewCreation(body));
} catch (err) {
if (isHttpError(err, 413)) throw err;
return json({ error: (err as Error).message }, { status: 400 });
}
}