지도크기오류 수정
This commit is contained in:
13
server.js
13
server.js
@@ -11,6 +11,7 @@ const __dirname = path.dirname(__filename);
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
const isDebug = process.env.NODE_ENV !== 'production' || process.env.DEBUG === 'true';
|
||||
|
||||
// Middleware
|
||||
app.use(cors());
|
||||
@@ -57,10 +58,10 @@ async function initializeDB() {
|
||||
// Routes
|
||||
app.get('/api/markers', async (req, res) => {
|
||||
const host = req.headers.host;
|
||||
console.log(`[API] GET /api/markers - Host: ${host} - Fetching from SQLite`);
|
||||
if (isDebug) console.log(`[API] GET /api/markers - Host: ${host} - Fetching from SQLite`);
|
||||
try {
|
||||
const markers = await db.all('SELECT * FROM markers');
|
||||
console.log(`[API] Found ${markers.length} markers`);
|
||||
if (isDebug) console.log(`[API] Found ${markers.length} markers`);
|
||||
// Convert isPublic from 0/1 to boolean
|
||||
const formattedMarkers = markers.map(m => ({
|
||||
...m,
|
||||
@@ -75,7 +76,7 @@ app.get('/api/markers', async (req, res) => {
|
||||
|
||||
app.post('/api/markers', async (req, res) => {
|
||||
const { id, name, ssid, password, lat, lng, securityType, iconType, description, addedBy, createdAt, isPublic } = req.body;
|
||||
console.log(`[API] POST /api/markers - Saving marker: ${name} (${ssid}) to SQLite`);
|
||||
if (isDebug) console.log(`[API] POST /api/markers - Saving marker: ${name} (${ssid}) to SQLite`);
|
||||
|
||||
try {
|
||||
await db.run(`
|
||||
@@ -83,7 +84,7 @@ app.post('/api/markers', async (req, res) => {
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`, [id, name, ssid, password, lat, lng, securityType, iconType, description || '', addedBy, createdAt, isPublic ? 1 : 0]);
|
||||
|
||||
console.log(`[API] Successfully saved marker: ${id}`);
|
||||
if (isDebug) console.log(`[API] Successfully saved marker: ${id}`);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -93,10 +94,10 @@ app.post('/api/markers', async (req, res) => {
|
||||
|
||||
app.delete('/api/markers/:id', async (req, res) => {
|
||||
const { id } = req.params;
|
||||
console.log(`[API] DELETE /api/markers/${id} - Deleting marker from SQLite`);
|
||||
if (isDebug) console.log(`[API] DELETE /api/markers/${id} - Deleting marker from SQLite`);
|
||||
try {
|
||||
await db.run('DELETE FROM markers WHERE id = ?', [id]);
|
||||
console.log(`[API] Successfully deleted marker: ${id}`);
|
||||
if (isDebug) console.log(`[API] Successfully deleted marker: ${id}`);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user