Files
CPLv4.0/pages/api/cpl/getTemperaturProzessorHandler.ts
ISA 0a20f91ba6 feat: fetchSystemData.mjs erweitert und optimiert
Analoge Eingänge und Systemdaten werden jetzt gemeinsam abgerufen und gespeichert
Einheitliche Benennung (input statt eingang) für analoge Eingänge
Datumssplittung als Hilfsfunktion ausgelagert
Kommentare und Beschreibung verbessert
2025-08-01 10:25:05 +02:00

34 lines
899 B
TypeScript

import { NextApiRequest, NextApiResponse } from "next";
import path from "path";
import fs from "fs/promises";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const { typ = "DIA0" } = req.query;
if (!["DIA0", "DIA1", "DIA2"].includes(typ as string)) {
return res
.status(400)
.json({ error: "Ungültiger Typ. Nur DIA0, DIA1 oder DIA2 erlaubt." });
}
try {
const filePath = path.join(
process.cwd(),
"mocks/device-cgi-simulator/chartsData/temperaturProzessor",
`${typ}.json`
);
const fileContent = await fs.readFile(filePath, "utf-8");
const json = JSON.parse(fileContent);
return res.status(200).json(json);
} catch (error) {
console.error("❌ Fehler beim Lesen der Datei:", error);
return res
.status(500)
.json({ error: "Datei konnte nicht gelesen werden." });
}
}