db 연결 패치
This commit is contained in:
12
server.js
12
server.js
@@ -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 });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user