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
+4 -2
View File
@@ -1,4 +1,5 @@
import { json } from '@sveltejs/kit';
import { jsonBody } from '$lib/server/request-body.js';
import { isHttpError, json } from '@sveltejs/kit';
import { db } from '$lib/server/db/index.js';
import { builtInPlans, parseBetaPlan } from '$lib/beta-plan.js';
export function GET() {
@@ -14,7 +15,7 @@ export function GET() {
}
export async function POST({ request }: { request: Request }) {
try {
const body = await request.json();
const body = await jsonBody(request);
if (typeof body.name !== 'string' || !body.name.trim() || body.name.length > 80)
throw new Error('Preset name must be 1–80 characters');
if (builtInPlans.some((p) => p.name === body.name.trim()))
@@ -27,6 +28,7 @@ export async function POST({ request }: { request: Request }) {
.run(body.name.trim(), JSON.stringify(plan));
return json({ ok: true });
} catch (error) {
if (isHttpError(error, 413)) throw error;
return json({ ok: false, error: (error as Error).message }, { status: 400 });
}
}