This commit is contained in:
@@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user