feat: APIs erstellt für Systemspannungen
This commit is contained in:
33
pages/api/cpl/getSystemspannung15VminusHandler.ts
Normal file
33
pages/api/cpl/getSystemspannung15VminusHandler.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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/systemspannung15Vminus",
|
||||
`${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." });
|
||||
}
|
||||
}
|
||||
33
pages/api/cpl/getSystemspannung15VplusHandler.ts
Normal file
33
pages/api/cpl/getSystemspannung15VplusHandler.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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/systemspannung15Vplus",
|
||||
`${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." });
|
||||
}
|
||||
}
|
||||
33
pages/api/cpl/getSystemspannung98VminusHandler.ts
Normal file
33
pages/api/cpl/getSystemspannung98VminusHandler.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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/systemspannung98Vminus",
|
||||
`${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." });
|
||||
}
|
||||
}
|
||||
33
pages/api/cpl/getTemperaturAdWandlerHandler.ts
Normal file
33
pages/api/cpl/getTemperaturAdWandlerHandler.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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-ad-wandler",
|
||||
`${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." });
|
||||
}
|
||||
}
|
||||
33
pages/api/cpl/getTemperaturProzessorHandler.ts
Normal file
33
pages/api/cpl/getTemperaturProzessorHandler.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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." });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user