db 연결 패치

This commit is contained in:
2026-03-01 15:02:44 +09:00
parent c0b3598f88
commit 5c4117658e
4 changed files with 25 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import "dotenv/config";
import express from 'express';
import mysql from 'mysql2/promise';
import cors from 'cors';
@@ -55,7 +56,8 @@ async function initializeDB() {
const [rows] = await pool.query('SELECT COUNT(*) as count FROM markers');
console.log(`[DB] Current Status: ${rows[0].count} markers stored in database.`);
} catch (error) {
console.error('[DB] MariaDB connection failed:', error.message);
console.error('[DB] MariaDB connection failed details:', error);
console.error('[DB] Host:', dbConfig.host);
process.exit(1);
}
}
@@ -74,8 +76,8 @@ app.get('/api/markers', async (req, res) => {
}));
res.json(formattedMarkers);
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Failed to fetch markers' });
console.error('[API] GET Markers Error:', error);
res.status(500).json({ error: 'Failed to fetch markers', detail: error.message });
}
});
@@ -97,8 +99,8 @@ app.post('/api/markers', async (req, res) => {
if (isDebug) console.log(`[API] Successfully saved marker: ${id}`);
res.json({ success: true });
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Failed to save marker' });
console.error('[API] POST Marker Error:', error);
res.status(500).json({ error: 'Failed to save marker', detail: error.message });
}
});