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/temperatur-prozessor", `${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." }); } }