Daten von CPL bekommen DIA0- DIA2 ISO und RSL
This commit is contained in:
@@ -11,8 +11,8 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
return res.status(400).json({ error: "❌ Fehlende Parameter" });
|
||||
}
|
||||
|
||||
// Dateipfad zusammensetzen
|
||||
const filePath = path.join(
|
||||
// Dateipfad zusammensetzen (bevorzugt chartsData; Fallback ohne chartsData für ältere Skriptversionen)
|
||||
const preferred = path.join(
|
||||
process.cwd(),
|
||||
"mocks",
|
||||
"device-cgi-simulator",
|
||||
@@ -22,11 +22,25 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
`${messart}`,
|
||||
`${dia}.json`
|
||||
);
|
||||
const legacy = path.join(
|
||||
process.cwd(),
|
||||
"mocks",
|
||||
"device-cgi-simulator",
|
||||
"cable-monitoring-data",
|
||||
`slot${slot}`,
|
||||
`${messart}`,
|
||||
`${dia}.json`
|
||||
);
|
||||
const filePath = fs.existsSync(preferred)
|
||||
? preferred
|
||||
: fs.existsSync(legacy)
|
||||
? legacy
|
||||
: null;
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return res
|
||||
.status(404)
|
||||
.json({ error: `❌ Datei nicht gefunden: ${filePath}` });
|
||||
if (!filePath) {
|
||||
return res.status(404).json({
|
||||
error: `❌ Datei nicht gefunden. Erwartet unter \n- ${preferred}\n- ${legacy}`,
|
||||
});
|
||||
}
|
||||
|
||||
const fileContent = fs.readFileSync(filePath, "utf-8");
|
||||
|
||||
Reference in New Issue
Block a user