Files
ISA 3896381a8f Debug-Logging zentralisiert: Nutzung von process.env.NEXT_PUBLIC_DEBUG_LOG entfernt und auf getDebugLog() mit config.json umgestellt
- Alle Vorkommen von process.env.NEXT_PUBLIC_DEBUG_LOG entfernt
- Debug-Konfiguration erfolgt jetzt ausschließlich über public/config.json
- getDebugLog()-Utility überall verwendet
- .env-Dateien werden für Debug-Logging nicht mehr benötigt
- Alle betroffenen Komponenten, Services und API
2025-08-22 11:10:40 +02:00

42 lines
1.4 KiB
JavaScript

// pages/api/talas_v5_DB/pois/addPoi.js
import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren
import { getDebugLog } from "../../../../utils/configUtils";
export default async function handler(req, res) {
const pool = getPool(); // Singleton-Pool verwenden
if (req.method === "POST") {
const { name, poiTypeId, latitude, longitude, idLD } = req.body;
if (getDebugLog()) {
console.log("Received data:", req.body); // Überprüfen der empfangenen Daten
}
const query =
"INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)";
const point = `POINT(${longitude} ${latitude})`;
const values = [name, poiTypeId, point, idLD];
let connection;
try {
connection = await pool.getConnection(); // Hole eine Verbindung aus dem Pool
// Verwende die Verbindung, um die Query auszuführen
const [results] = await connection.query(query, values);
res.status(200).json({
id: results.insertId,
message: "Standort erfolgreich hinzugefügt",
});
} catch (error) {
console.error("Fehler beim Einfügen des Standorts:", error);
res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
} finally {
if (connection) connection.release(); // Gib die Verbindung in den Pool zurück
}
} else {
res.setHeader("Allow", ["POST"]);
res.status(405).end(`Method ${req.method} Not Allowed`);
}
}