refactor: API-Dateien konsequent auf *APIHandler.ts umbenannt und MockData-Handling optimiert
- Einheitliches Naming für API-Routen: *APIHandler.ts - Mock-Daten aus /apiMockData/SERVICE/ werden über API bereitgestellt - API-Endpoints sofort erkennbar und verständlich - Projektstruktur deutlich klarer und wartungsfreundlicher
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// /apiMockData/SERVICE/SystemMockData.js
|
||||
var win_appVersion = "0.02";
|
||||
var win_deviceName = "CPLV4_Maschen";
|
||||
var win_mac1 = "0 48 86 81 46 143";
|
||||
@@ -1,4 +1,4 @@
|
||||
// public/CPLmockData/SERVICE/ae.js
|
||||
// /apiMockData/SERVICE/analogeEingaengeMockData.js
|
||||
var win_analogeEingaenge1 = [1, 0, "Sensor2", 1, 1, 0, 1]; // Eingang 1
|
||||
var win_analogeEingaenge2 = [2, 22.91, "Feuchtigkeit", 1, 1, 1, 0]; // Eingang 2
|
||||
var win_analogeEingaenge3 = [3, 0, "Test", 1, 1, 0, 1]; // Eingang 3
|
||||
@@ -1,3 +1,3 @@
|
||||
// public/CPLmockData/SERVICE/da.js
|
||||
// /apiMockData/SERVICE/digitaleAusgaengeMockData.js
|
||||
win_da_state = [1, 0, 1, 0];
|
||||
win_da_bezeichnung = ["Ausgang1", "Ausgang2", "Ausgang3", "Ausgang4"];
|
||||
@@ -1,4 +1,4 @@
|
||||
// apiMockData/SERVICE/de.js
|
||||
// apiMockData/SERVICE/digitaleEingaengeMockData.js
|
||||
|
||||
// Zustand -> DESxx xx =Nr Eingang 1-32 80-83 = BGT 1 bis 4
|
||||
var win_de_state = [
|
||||
@@ -1,4 +1,4 @@
|
||||
// /public/CPLmockData/SERVICE/kueData.js
|
||||
// /apiMockData/SERVICE/kabelueberwachungMockData.js
|
||||
//Modul vorhanden 1 = vorhanden, 0 = nicht vorhanden
|
||||
var win_kueOnline = [
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
@@ -1,4 +1,4 @@
|
||||
// /apiMockData/SERVICE/last20Messages.js
|
||||
// /apiMockData/SERVICE/last20MessagesMockData.js
|
||||
var win_last20Messages = `
|
||||
<tr><td>16750</td><td>03501</td><td>2024-10-23 15:08:58:000</td><td>Modul 26 Isofehler kommend</td><td>1</td></tr>
|
||||
<tr><td>16749</td><td>03201</td><td>2024-10-23 15:07:24:000</td><td>Modul 23 Isofehler gehend</td><td>0</td></tr>
|
||||
@@ -1,4 +1,4 @@
|
||||
// public/CPL/SERVICE/opcua.js
|
||||
// /apiMockData/SERVICE/opcuaMockData.js
|
||||
//-------OPCUA Information Lesen----------------
|
||||
var win_opcUaZustand = "1";
|
||||
var win_opcUaActiveClientCount = "0";
|
||||
@@ -6,5 +6,5 @@
|
||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||
|
||||
*/
|
||||
const webVersion = "1.6.221";
|
||||
const webVersion = "1.6.222";
|
||||
export default webVersion;
|
||||
|
||||
26
pages/api/cpl/analogeEingaengeAPIHandler.ts
Normal file
26
pages/api/cpl/analogeEingaengeAPIHandler.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// /pages/api/cpl/analogeEingaengeAPIHandler.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const filePath = path.join(
|
||||
process.cwd(),
|
||||
"apiMockData",
|
||||
"SERVICE",
|
||||
"analogeEingaengeMockData.js"
|
||||
);
|
||||
|
||||
try {
|
||||
const data = await fs.readFile(filePath, "utf-8");
|
||||
|
||||
res.setHeader("Content-Type", "text/javascript");
|
||||
res.status(200).send(data);
|
||||
} catch (error) {
|
||||
res.status(404).json({ error: "File not found" });
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// /pages/api/cpl/digitalOutputs.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const filePath = path.join(process.cwd(), "apiMockData", "SERVICE", "da.js");
|
||||
|
||||
try {
|
||||
const data = await fs.readFile(filePath, "utf-8");
|
||||
res.status(200).send(data);
|
||||
} catch (error) {
|
||||
res.status(404).json({ error: "File not found" });
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// /pages/api/cpl/kueData.ts
|
||||
// /pages/api/cpl/digitalOutputsAPIHandler.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
@@ -12,7 +12,7 @@ export default async function handler(
|
||||
process.cwd(),
|
||||
"apiMockData",
|
||||
"SERVICE",
|
||||
"kueData.js"
|
||||
"digitaleAusgaengeMockData.js"
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -1,21 +0,0 @@
|
||||
// /pages/api/cpl/digitaleEingaenge.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const filePath = path.join(process.cwd(), "apiMockData", "SERVICE", "de.js");
|
||||
|
||||
try {
|
||||
const data = await fs.readFile(filePath, "utf-8");
|
||||
|
||||
res.setHeader("Content-Type", "text/javascript"); // wichtig!
|
||||
res.status(200).send(data);
|
||||
} catch (error) {
|
||||
res.status(404).json({ error: "File not found" });
|
||||
}
|
||||
}
|
||||
26
pages/api/cpl/digitaleEingaengeAPIHandler.ts
Normal file
26
pages/api/cpl/digitaleEingaengeAPIHandler.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// /pages/api/cpl/digitaleEingaengeAPIHandler.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const filePath = path.join(
|
||||
process.cwd(),
|
||||
"apiMockData",
|
||||
"SERVICE",
|
||||
"digitaleEingaengeMockData.js"
|
||||
);
|
||||
|
||||
try {
|
||||
const data = await fs.readFile(filePath, "utf-8");
|
||||
|
||||
res.setHeader("Content-Type", "text/javascript"); // wichtig!
|
||||
res.status(200).send(data);
|
||||
} catch (error) {
|
||||
res.status(404).json({ error: "File not found" });
|
||||
}
|
||||
}
|
||||
24
pages/api/cpl/kabelueberwachungAPIHandler.ts
Normal file
24
pages/api/cpl/kabelueberwachungAPIHandler.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
// /pages/api/cpl/kabelueberwachungAPIHandler.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const filePath = path.join(
|
||||
process.cwd(),
|
||||
"apiMockData",
|
||||
"SERVICE",
|
||||
"kabelueberwachungMockData.js"
|
||||
);
|
||||
|
||||
try {
|
||||
const data = await fs.readFile(filePath, "utf-8");
|
||||
res.status(200).send(data);
|
||||
} catch (error) {
|
||||
res.status(404).json({ error: "File not found" });
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// /pages/api/cpl/last20Messages.ts
|
||||
// /pages/api/cpl/last20MessagesAPIHandler.ts
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
@@ -11,7 +11,7 @@ export default async function handler(
|
||||
process.cwd(),
|
||||
"apiMockData",
|
||||
"SERVICE",
|
||||
"last20Messages.js"
|
||||
"last20MessagesMockData.js"
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -1,4 +1,4 @@
|
||||
// /pages/api/cpl/systemSettings.ts
|
||||
// /pages/api/cpl/opcuaSettingsAPIHandler.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
@@ -12,7 +12,7 @@ export default async function handler(
|
||||
process.cwd(),
|
||||
"apiMockData",
|
||||
"SERVICE",
|
||||
"system.js"
|
||||
"opcuaMockData.js"
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -1,4 +1,4 @@
|
||||
// /pages/api/cpl/slotData.ts
|
||||
// /pages/api/cpl/slotDataAPIHandler.ts
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
@@ -1,4 +1,4 @@
|
||||
// /pages/api/cpl/opcuaSettings.ts
|
||||
// /pages/api/cpl/systemSettingsAPIHandler.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
@@ -12,7 +12,7 @@ export default async function handler(
|
||||
process.cwd(),
|
||||
"apiMockData",
|
||||
"SERVICE",
|
||||
"opcua.js"
|
||||
"systemMockData.js"
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -1,4 +1,4 @@
|
||||
// /pages/api/cpl/tdmData.ts
|
||||
// /pages/api/cpl/tdmDataAPIHandler.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
@@ -1,4 +1,4 @@
|
||||
// /pages/api/cpl/tdrData.ts
|
||||
// /pages/api/cpl/tdrDataAPIHandler.ts
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
Reference in New Issue
Block a user