feat: Healthcheck um Webservices, API-Routen und .env-Prüfungen erweitert
- Externe Webservices von TALAS V5 integriert und geprüft (Statuscode + Antwortstruktur) - Eigene API-Endpunkte wie /api/talas_v5_DB/getDevices hinzugefügt und validiert - Prüfung von NEXT_PUBLIC_USE_MOCKS zur Vermeidung von Mockdaten in Produktion - Validierung der Umgebungsvariablen wie DB_HOST, DB_NAME und NODE_ENV ergänzt - Response-Status 200 bei vollständigem Erfolg, 207 bei Teilfehlern - Verbesserung der JSON-Antwortstruktur zur einfacheren Analyse
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
import getPool from "../../../../utils/mysqlPool";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
console.log("Request erhalten:", req.method, req.body); // Debugging
|
||||
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
|
||||
console.log("Request erhalten:", req.method, req.body); // Debugging
|
||||
}
|
||||
|
||||
const pool = getPool();
|
||||
|
||||
@@ -15,7 +17,9 @@ export default async function handler(req, res) {
|
||||
const { idLocation, idMap, x, y } = req.body;
|
||||
|
||||
if (!idLocation || !idMap || x === undefined || y === undefined) {
|
||||
return res.status(400).json({ error: "Alle Felder (idLocation, idMap, x, y) sind erforderlich" });
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Alle Felder (idLocation, idMap, x, y) sind erforderlich" });
|
||||
}
|
||||
|
||||
let connection;
|
||||
@@ -23,18 +27,25 @@ export default async function handler(req, res) {
|
||||
try {
|
||||
// Verbindung zur Datenbank herstellen
|
||||
connection = await pool.getConnection();
|
||||
const query = "UPDATE location_coordinates SET x = ?, y = ? WHERE idLocation = ? AND idMaps = ?";
|
||||
const query =
|
||||
"UPDATE location_coordinates SET x = ?, y = ? WHERE idLocation = ? AND idMaps = ?";
|
||||
const [result] = await connection.query(query, [x, y, idLocation, idMap]);
|
||||
|
||||
// Erfolgreiche Aktualisierung prüfen
|
||||
if (result.affectedRows > 0) {
|
||||
return res.status(200).json({ success: true, message: "Koordinaten erfolgreich aktualisiert" });
|
||||
return res
|
||||
.status(200)
|
||||
.json({ success: true, message: "Koordinaten erfolgreich aktualisiert" });
|
||||
} else {
|
||||
return res.status(404).json({ error: "Kein Eintrag gefunden, der aktualisiert werden konnte" });
|
||||
return res
|
||||
.status(404)
|
||||
.json({ error: "Kein Eintrag gefunden, der aktualisiert werden konnte" });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Aktualisieren der Koordinaten:", error);
|
||||
return res.status(500).json({ error: "Interner Serverfehler beim Aktualisieren der Koordinaten" });
|
||||
return res
|
||||
.status(500)
|
||||
.json({ error: "Interner Serverfehler beim Aktualisieren der Koordinaten" });
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.release();
|
||||
|
||||
Reference in New Issue
Block a user