chore: rename service/thunk files to follow get/fetch naming convention

This commit is contained in:
ISA
2025-06-20 14:07:29 +02:00
parent 0388512f51
commit 38ee1ae381
13 changed files with 25 additions and 20 deletions

View File

@@ -0,0 +1,39 @@
// /pages/api/cpl/getAnalogInputsHistory.ts
import path from "path";
import fs from "fs/promises";
import type { NextApiRequest, NextApiResponse } from "next";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
try {
const result: Record<number, any[]> = {};
for (let i = 1; i <= 8; i++) {
const filePath = path.join(
process.cwd(),
"mocks",
"device-cgi-simulator",
"analogInputsHistoryData",
`analogInput${i}.json`
);
try {
const fileContent = await fs.readFile(filePath, "utf-8");
result[99 + i] = JSON.parse(fileContent); // z.B. 100 für AE1, 101 für AE2
} catch (err) {
console.warn(
`Mock-Datei für analogInput${i} nicht gefunden oder fehlerhaft.`
);
result[99 + i] = [];
}
}
res.status(200).json(result);
} catch (error) {
console.error("Fehler beim Laden der analogen Eingänge (Mock):", error);
res.status(500).json({ error: "Fehler beim Laden der Mock-Daten." });
}
}