Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -4,11 +4,12 @@ import { db } from '$lib/server/db/index.js';
|
||||
import { getDeployment } from '$lib/server/provisioning/index.js';
|
||||
|
||||
export async function GET({ params, url }: { params: { id: string }; url?: URL }) {
|
||||
const lifecycle = getDeployment(params.id, { events: url?.searchParams.get('events') === 'recent' ? 'recent' : 'all' });
|
||||
const lifecycle = getDeployment(params.id, {
|
||||
events: url?.searchParams.get('events') === 'recent' ? 'recent' : 'all'
|
||||
});
|
||||
if (lifecycle) return json(lifecycle);
|
||||
const dep = db()
|
||||
.prepare('SELECT * FROM deployments WHERE id = ?')
|
||||
.get(params.id) as Record<string, unknown> | undefined;
|
||||
const dep = db().prepare('SELECT * FROM deployments WHERE id = ?').get(params.id) as
|
||||
Record<string, unknown> | undefined;
|
||||
if (!dep) throw error(404, 'deployment not found');
|
||||
|
||||
const servers = db()
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { cancelProvisioningJob, rebalanceCancellationBlocker } from '$lib/server/provisioning/cancellation.js';
|
||||
import {
|
||||
cancelProvisioningJob,
|
||||
rebalanceCancellationBlocker
|
||||
} from '$lib/server/provisioning/cancellation.js';
|
||||
import { kickProvisioning } from '$lib/server/pipeline/worker.js';
|
||||
|
||||
export function POST({ params }: { params: { id: string } }) {
|
||||
if (!cancelProvisioningJob(params.id)) return json({ error: rebalanceCancellationBlocker(params.id)
|
||||
?? 'This operation can no longer be cancelled. Refresh to see its current state.' }, { status: 409 });
|
||||
if (!cancelProvisioningJob(params.id))
|
||||
return json(
|
||||
{
|
||||
error:
|
||||
rebalanceCancellationBlocker(params.id) ??
|
||||
'This operation can no longer be cancelled. Refresh to see its current state.'
|
||||
},
|
||||
{ status: 409 }
|
||||
);
|
||||
void kickProvisioning();
|
||||
return json({ ok: true });
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { resumeVerification, resumeCleanup, resumeRebuild } from '$lib/server/provisioning/index.js';
|
||||
import {
|
||||
resumeVerification,
|
||||
resumeCleanup,
|
||||
resumeRebuild
|
||||
} from '$lib/server/provisioning/index.js';
|
||||
import { kick } from '$lib/server/pipeline/worker.js';
|
||||
|
||||
export function POST({ params }: { params: { id: string } }) {
|
||||
if (!resumeVerification(params.id) && !resumeCleanup(params.id) && !resumeRebuild(params.id)) return json({ error: 'This operation cannot resume. Refresh and inspect its server.' }, { status: 409 });
|
||||
void kick().catch(err => console.error('[deployment] verification kick failed:', err));
|
||||
if (!resumeVerification(params.id) && !resumeCleanup(params.id) && !resumeRebuild(params.id))
|
||||
return json(
|
||||
{ error: 'This operation cannot resume. Refresh and inspect its server.' },
|
||||
{ status: 409 }
|
||||
);
|
||||
void kick().catch((err) => console.error('[deployment] verification kick failed:', err));
|
||||
return json({ ok: true }, { status: 202 });
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ export function GET() {
|
||||
|
||||
export async function POST({ request }: { request: Request }) {
|
||||
const body = await request.json().catch(() => null);
|
||||
if (!Array.isArray(body?.servers) || !body.servers.every((name: unknown) => typeof name === 'string')) {
|
||||
if (
|
||||
!Array.isArray(body?.servers) ||
|
||||
!body.servers.every((name: unknown) => typeof name === 'string')
|
||||
) {
|
||||
return json({ error: 'A reviewed server list is required.' }, { status: 400 });
|
||||
}
|
||||
let result: ReturnType<typeof queueHouseParty>;
|
||||
@@ -18,6 +21,6 @@ export async function POST({ request }: { request: Request }) {
|
||||
return json({ ok: false, error: (err as Error).message }, { status: 409 });
|
||||
}
|
||||
if (!result.ok) return json(result, { status: 409 });
|
||||
void kick().catch(err => console.error('[house-party] worker kick failed:', err));
|
||||
void kick().catch((err) => console.error('[house-party] worker kick failed:', err));
|
||||
return json(result, { status: 202 });
|
||||
}
|
||||
|
||||
@@ -4,8 +4,12 @@ import { previewCreation } from '$lib/server/provisioning/index.js';
|
||||
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 launch selection.');
|
||||
if (body.blueprintId !== undefined) throw new Error('Collections use target counts. Use /api/deployment-collections/preview to preview only missing servers.');
|
||||
if (!body || typeof body !== 'object' || Array.isArray(body))
|
||||
throw new Error('Provide a launch selection.');
|
||||
if (body.blueprintId !== undefined)
|
||||
throw new Error(
|
||||
'Collections use target counts. Use /api/deployment-collections/preview to preview only missing servers.'
|
||||
);
|
||||
return json(previewCreation(body));
|
||||
} catch (err) {
|
||||
return json({ error: (err as Error).message }, { status: 400 });
|
||||
|
||||
Reference in New Issue
Block a user