Add Prettier and ESLint tooling (Refs #77)

This commit is contained in:
2026-10-09 15:56:13 -04:00
parent 8ed059b8d3
commit 16469e2d43
711 changed files with 99737 additions and 28286 deletions
+26 -6
View File
@@ -1,14 +1,34 @@
import { json } from '@sveltejs/kit';
import { RebalanceError, previewRebalance, rebalanceReport, startRebalance, stopRebalance } from '$lib/server/rebalancing/index.js';
import {
RebalanceError,
previewRebalance,
rebalanceReport,
startRebalance,
stopRebalance
} from '$lib/server/rebalancing/index.js';
export function GET() { return json(rebalanceReport()); }
export function GET() {
return json(rebalanceReport());
}
export async function POST({ request }: { request: Request }) {
try {
const body = await request.json();
if (!body || typeof body !== 'object' || Array.isArray(body)) throw new RebalanceError('Provide a rebalance action.');
if (!body || typeof body !== 'object' || Array.isArray(body))
throw new RebalanceError('Provide a rebalance action.');
if (body.action === 'preview') return json({ preview: previewRebalance(body.settings) });
if (body.action === 'start' && typeof body.previewId === 'string' && body.previewId.length <= 100) return json({ run: startRebalance(body.previewId) });
if (body.action === 'stop' && typeof body.id === 'string' && body.id.length <= 100) return json({ run: stopRebalance(body.id) });
if (
body.action === 'start' &&
typeof body.previewId === 'string' &&
body.previewId.length <= 100
)
return json({ run: startRebalance(body.previewId) });
if (body.action === 'stop' && typeof body.id === 'string' && body.id.length <= 100)
return json({ run: stopRebalance(body.id) });
throw new RebalanceError('Choose a supported rebalance action.');
} catch (error) { return json({ error: (error as Error).message }, { status: error instanceof RebalanceError ? error.status : 400 }); }
} catch (error) {
return json(
{ error: (error as Error).message },
{ status: error instanceof RebalanceError ? error.status : 400 }
);
}
}