Version 1.0.1.5 delete linsColorApi.js because was mock file

This commit is contained in:
ISA
2024-09-05 11:53:21 +02:00
parent 3d8ecb8287
commit 094e27e147
2 changed files with 6 additions and 65 deletions

View File

@@ -1,64 +0,0 @@
// /pages/api/linesColorApi.js
// http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict
//In DB gis_lines idLD und idModul anpassen entsprechend
// /pages/api/linesColorApi.js
import NextCors from "nextjs-cors";
export default async function handler(req, res) {
// Run the cors middleware
await NextCors(req, res, {
// Options
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
origin: "*", // Erlauben Sie alle Ursprünge, oder geben Sie spezifische Ursprünge an
optionsSuccessStatus: 200, // Legacy-Browser-Unterstützung für 204
});
const response = {
Name: "Liste aller Statis der Linien",
Zeitstempel: new Date().toISOString(), // Aktuellen Zeitstempel hinzufügen
IdMap: "10",
Statis: [
/* {
IdLD: 50922,
Modul: 1,
DpName: "KUE01_Ausfall",
ModulName: "42 Wippershain Sender",
// ModulTyp: "nicht vorhanden",
ModulTyp: "KÜ705-FO",
Message: "KUEG 01: 42 Wippershain Sender Messwerkausfall kommend",
Level: 4,
PrioColor: "#FFFF00",
PrioName: "system",
Value: "10 MOhm",
},
{
IdLD: 25440,
Modul: 3,
DpName: "KUE03_Ausfall",
ModulName: "42 Solz Sender",
//ModulTyp: "nicht vorhanden",
ModulTyp: "KÜSS V2",
Message: "KUEG 03: 42 Solz Sender Messwerkausfall kommend",
Level: 4,
PrioColor: "#FF0000",
PrioName: "system",
Value: "10 MOhm",
},
{
IdLD: 25440,
Modul: 4,
DpName: "KUE04_Ausfall",
ModulName: "42/13 Bad Hersfeld Gaswerk",
ModulTyp: "Kue705-FO",
Message: "KUEG 04: 42/13 Bad Hersfeld Gaswerk Messwerkausfall kommend",
Level: 4,
PrioColor: "#FF00FF",
PrioName: "system",
Value: "10 MOhm",
}, */
],
};
res.status(200).json(response);
}

View File

@@ -4,16 +4,21 @@
import getPool from "../../utils/mysqlPool"; // Verwende den Singleton-Pool import getPool from "../../utils/mysqlPool"; // Verwende den Singleton-Pool
export default async function handler(req, res) { export default async function handler(req, res) {
let connection;
try { try {
const pool = getPool(); // Hole den Pool const pool = getPool(); // Hole den Pool
connection = await pool.getConnection(); // Hole die Verbindung
// Führe die Abfrage aus // Führe die Abfrage aus
const [results] = await pool.query("SELECT id, name FROM area WHERE id = ?", [req.query.id]); const [results] = await connection.query("SELECT id, name FROM area WHERE id = ?", [req.query.id]);
// Sende die Antwort zurück // Sende die Antwort zurück
res.status(200).json(results); res.status(200).json(results);
} catch (error) { } catch (error) {
console.error("Fehler beim Abrufen der API", error); console.error("Fehler beim Abrufen der API", error);
res.status(500).json({ error: "Fehler bei der Abfrage" }); res.status(500).json({ error: "Fehler bei der Abfrage" });
} finally {
if (connection) connection.release(); // Gib die Verbindung zurück in den Pool
} }
} }