Structured

This commit is contained in:
2026-02-15 23:51:57 +01:00
parent e552ecb6e2
commit 6370219165
+54 -53
View File
@@ -55,60 +55,7 @@ export function UPGRADE(client: WebSocket, server: WebSocketServer) {
break;
}
/* ---------------- SUBMIT ---------------- */
case "submit": {
const { runId } = msg;
if (!runId) {
client.send(JSON.stringify({ ok: false, error: "runId required" }));
return;
}
const liveRun = await Core.getLiveRun(runId);
if (!liveRun) {
client.send(
JSON.stringify({
ok: false,
error: "Run is not live or does not exist",
}),
);
return;
}
const run = await Core.submitRun(supabase, liveRun, session[0].id);
client.send(
JSON.stringify({
ok: true,
type: "submit",
data: run,
}),
);
break;
}
/* ---------------- DELETE ---------------- */
case "delete": {
const { runId } = msg;
if (!runId) {
client.send(JSON.stringify({ ok: false, error: "runId required" }));
return;
}
const run = await Core.removeLiveRun(runId);
client.send(
JSON.stringify({
ok: true,
type: "delete",
data: run,
}),
);
break;
}
case "move": {
const { runId, moves, file, language } = msg;
@@ -167,6 +114,60 @@ export function UPGRADE(client: WebSocket, server: WebSocketServer) {
break;
}
/* ---------------- SUBMIT ---------------- */
case "submit": {
const { runId } = msg;
if (!runId) {
client.send(JSON.stringify({ ok: false, error: "runId required" }));
return;
}
const liveRun = await Core.getLiveRun(runId);
if (!liveRun) {
client.send(
JSON.stringify({
ok: false,
error: "Run is not live or does not exist",
}),
);
return;
}
const run = await Core.submitRun(supabase, liveRun, session[0].id);
client.send(
JSON.stringify({
ok: true,
type: "submit",
data: run,
}),
);
break;
}
/* ---------------- DELETE ---------------- */
case "delete": {
const { runId } = msg;
if (!runId) {
client.send(JSON.stringify({ ok: false, error: "runId required" }));
return;
}
const run = await Core.removeLiveRun(runId);
client.send(
JSON.stringify({
ok: true,
type: "delete",
data: run,
}),
);
break;
}
default:
client.send(
JSON.stringify({