esLint
This commit is contained in:
@@ -34,7 +34,6 @@ if (!mockFilePath) {
|
||||
|
||||
// Funktion zum Parsen bei jsSimulatedProd
|
||||
function extractMockData(raw: string) {
|
||||
const context = {};
|
||||
const func = new Function(
|
||||
"context",
|
||||
`
|
||||
@@ -81,11 +80,9 @@ export default async function handler(
|
||||
|
||||
const rawContent = fs.readFileSync(mockFilePath!, "utf-8");
|
||||
|
||||
// 3️⃣ JSON vs JS Verarbeitung
|
||||
const data =
|
||||
mode === "json" ? JSON.parse(rawContent) : extractMockData(rawContent);
|
||||
|
||||
// 4️⃣ Aktualisieren der Felder
|
||||
if (typeof label === "string") data.win_de_label[id - 1] = label;
|
||||
if (typeof invert === "number") data.win_de_invert[id - 1] = invert;
|
||||
if (typeof timeFilter === "number")
|
||||
@@ -97,7 +94,6 @@ export default async function handler(
|
||||
if (typeof eingangOffline === "number")
|
||||
data.win_de_offline[id - 1] = eingangOffline;
|
||||
|
||||
// 5️⃣ Speichern
|
||||
if (mode === "json") {
|
||||
fs.writeFileSync(mockFilePath!, JSON.stringify(data, null, 2), "utf-8");
|
||||
} else {
|
||||
@@ -128,8 +124,12 @@ var win_de_label = ${JSON.stringify(data.win_de_label, null, 2)};
|
||||
weighting,
|
||||
eingangOffline,
|
||||
});
|
||||
} catch (err: any) {
|
||||
console.error("Fehler beim Schreiben:", err);
|
||||
} catch (err: unknown) {
|
||||
if (err instanceof Error) {
|
||||
console.error("Fehler beim Schreiben:", err.message);
|
||||
} else {
|
||||
console.error("Unbekannter Fehler beim Schreiben:", err);
|
||||
}
|
||||
return res.status(500).json({ error: "Update fehlgeschlagen" });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user