- API-Handler für /api/cpl/getAnalogInputsHistory überarbeitet - `zeitraum` (DIA0, DIA1, DIA2) und `eingang` (1–8) sind jetzt Pflichtfelder - Bei fehlenden oder ungültigen Parametern strukturierte Fehlerantwort mit Beispielen - Daten werden nun gezielt pro Eingang und Zeitraum geladen (z. B. AE3 + DIA1) - Bessere Fehlerbehandlung bei nicht vorhandenen Dateien
22 lines
622 B
TypeScript
22 lines
622 B
TypeScript
// /pages/api/cpl/getAnalogInputsHandler.ts
|
|
|
|
import { NextApiRequest, NextApiResponse } from "next";
|
|
import fs from "fs";
|
|
import path from "path";
|
|
|
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
try {
|
|
const filePath = path.join(
|
|
process.cwd(),
|
|
"mocks/device-cgi-simulator/SERVICE/analogInputsMockData.json"
|
|
);
|
|
const jsonContent = fs.readFileSync(filePath, "utf-8");
|
|
const data = JSON.parse(jsonContent);
|
|
res.status(200).json(data);
|
|
return;
|
|
} catch (error) {
|
|
console.error(error);
|
|
res.status(500).json({ error: "Internal Server Error" });
|
|
}
|
|
}
|