Runde 3: Probeabend neben Startklar – sechs Punkte, die nur an Filipes Rechner messbar sind, messen selbst und bleiben gespeichert

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-05 14:56:43 +01:00
co-authored by Claude Opus 5.5
parent 363151d8b6
commit c78bf01594
62 changed files with 1373 additions and 842 deletions
+53
View File
@@ -0,0 +1,53 @@
/* =====================================================================
DER PROBEABEND (05.11.2026, Perfektionsplan Runde 3)
Was nur an Filipes Rechner messbar ist (Saal-Fenster über GTA,
Freistellen auf der RTX, Clip aus dem echten OBS, Stream Deck …), misst
die Seite selbst – hier wird nur das ERGEBNIS je Punkt aufgehoben, damit
die Regie es beim nächsten Mal noch weiß. Eine Zeile in `einstellungen`
(kein neues Schema), nur die Regie liest und schreibt.
===================================================================== */
import { db, protokolliere, echteIp } from "./workspace.js";
export const PROBE_PUNKTE = ["fenster", "freistellen", "clip", "meinmix", "streamdeck", "lautheit"];
const STAENDE = ["offen", "geht", "knapp", "geht_nicht"];
const SCHLUESSEL = "reaktion_probeabend";
export function probeLesen() {
try {
const z = db().prepare("SELECT wert FROM einstellungen WHERE schluessel = ?").get(SCHLUESSEL);
const roh = z ? JSON.parse(z.wert) : {};
const aus = {};
for (const p of PROBE_PUNKTE) {
const e = roh[p];
aus[p] = e && STAENDE.includes(e.stand) ? { stand: e.stand, wann: String(e.wann || ""), wert: String(e.wert || "").slice(0, 160) } : { stand: "offen", wann: "", wert: "" };
}
return aus;
} catch { return Object.fromEntries(PROBE_PUNKTE.map((p) => [p, { stand: "offen", wann: "", wert: "" }])); }
}
export function probeabendWege(probeRouter, { nurHost, kleinerRumpf }) {
probeRouter.use(["/workspace/api/reaktion/probeabend"], kleinerRumpf(1024));
probeRouter.get("/workspace/api/reaktion/probeabend", nurHost, (req, res) => {
res.set("Cache-Control", "no-store");
res.json({ punkte: probeLesen() });
});
probeRouter.put("/workspace/api/reaktion/probeabend", nurHost, (req, res) => {
try {
const punkt = String(req.body?.punkt || "");
const stand = String(req.body?.stand || "");
if (!PROBE_PUNKTE.includes(punkt) || !STAENDE.includes(stand)) return res.status(400).json({ fehler: "probe_unklar" });
const wert = String(req.body?.wert ?? "").replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, 160);
const alle = probeLesen();
alle[punkt] = { stand, wann: new Date().toISOString(), wert };
db().prepare(`INSERT INTO einstellungen (schluessel, wert, geaendert, von) VALUES (?,?,?,?)
ON CONFLICT(schluessel) DO UPDATE SET wert = excluded.wert, geaendert = excluded.geaendert, von = excluded.von`)
.run(SCHLUESSEL, JSON.stringify(alle), new Date().toISOString(), req.person.id);
protokolliere("reaktion_probeabend", { personId: req.person.id, detail: `${punkt}: ${stand}`, ip: echteIp(req) });
res.json({ punkte: alle });
} catch (f) {
console.error("[probeabend]", f?.message);
res.status(503).json({ fehler: "nicht_verfuegbar" });
}
});
}