33 lines
1002 B
JavaScript
33 lines
1002 B
JavaScript
// pages/api/talas_v5_DB/pois/poi-icons.js
|
|
import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren
|
|
|
|
export default async function handler(req, res) {
|
|
const pool = getPool(); // Singleton-Pool verwenden
|
|
|
|
if (req.method !== "GET") {
|
|
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
|
|
}
|
|
|
|
const query = `
|
|
SELECT p.idPoi, i.path
|
|
FROM poi p
|
|
JOIN poiTyp pt ON p.idPoiTyp = pt.idPoiTyp
|
|
JOIN poiicons i ON pt.icon = i.idpoiicons;
|
|
`;
|
|
|
|
let connection;
|
|
|
|
try {
|
|
connection = await pool.getConnection(); // Hole eine Verbindung aus dem Pool
|
|
|
|
// Ausführen der Abfrage mit dem Verbindungspool
|
|
const [results] = await connection.query(query);
|
|
res.status(200).json(results);
|
|
} catch (error) {
|
|
console.error("Fehler beim Abrufen der Icons:", error);
|
|
res.status(500).json({ error: "Fehler beim Abrufen der Icons" });
|
|
} finally {
|
|
if (connection) connection.release(); // Gib die Verbindung in den Pool zurück
|
|
}
|
|
}
|