// /pages/api/cpl/getDgitalInputsHandler.ts import fs from "fs"; import path from "path"; import type { NextApiRequest, NextApiResponse } from "next"; export default function handler(req: NextApiRequest, res: NextApiResponse) { try { const mode = process.env.NEXT_PUBLIC_CPL_MODE; if (mode === "json") { const filePath = path.join( process.cwd(), "mocks", "device-cgi-simulator", "SERVICE", "digitalInputsMockData.json" ); const fileContent = fs.readFileSync(filePath, "utf-8"); const json = JSON.parse(fileContent); return res.status(200).json(json); } return res.status(400).json({ error: "Ungültiger Modus" }); } catch (error) { console.error("❌ Fehler beim Parsen der digitalen Eingänge:", error); return res .status(500) .json({ error: "Fehler beim Parsen der digitalen Eingänge" }); } }