2026-04-07 18:55:06 +09:00
|
|
|
import express from 'express';
|
|
|
|
|
import cors from 'cors';
|
2026-04-11 18:02:32 +09:00
|
|
|
import adminRoutes from './routes/admin.js';
|
2026-04-13 15:20:46 +09:00
|
|
|
import menuRoutes from './routes/menus.js';
|
2026-04-13 16:48:05 +09:00
|
|
|
import noticeRoutes from './routes/notices.js';
|
2026-04-13 19:17:49 +09:00
|
|
|
import bossCrystalRoutes from './routes/boss-crystal.js';
|
|
|
|
|
import characterRoutes from './routes/character.js';
|
2026-04-07 18:55:06 +09:00
|
|
|
import { sequelize } from './lib/db.js';
|
2026-04-13 14:42:51 +09:00
|
|
|
import './models/index.js';
|
2026-04-07 18:55:06 +09:00
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
const PORT = process.env.PORT || 3000;
|
|
|
|
|
|
|
|
|
|
app.use(cors({
|
|
|
|
|
origin: process.env.NODE_ENV === 'production'
|
|
|
|
|
? 'https://maple.caadiq.co.kr'
|
|
|
|
|
: 'http://localhost:5173',
|
|
|
|
|
credentials: true,
|
|
|
|
|
}));
|
|
|
|
|
app.use(express.json());
|
|
|
|
|
|
2026-04-13 15:20:46 +09:00
|
|
|
app.use('/api/menus', menuRoutes);
|
2026-04-13 16:48:05 +09:00
|
|
|
app.use('/api/notices', noticeRoutes);
|
2026-04-13 19:17:49 +09:00
|
|
|
app.use('/api/boss-crystal', bossCrystalRoutes);
|
|
|
|
|
app.use('/api/character', characterRoutes);
|
2026-04-11 18:02:32 +09:00
|
|
|
app.use('/api/admin', adminRoutes);
|
2026-04-07 18:55:06 +09:00
|
|
|
|
|
|
|
|
app.get('/api/health', (_req, res) => {
|
|
|
|
|
res.json({ status: 'ok' });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
async function start() {
|
|
|
|
|
try {
|
|
|
|
|
await sequelize.authenticate();
|
|
|
|
|
console.log('DB 연결 성공');
|
|
|
|
|
await sequelize.sync();
|
|
|
|
|
console.log('테이블 동기화 완료');
|
|
|
|
|
|
|
|
|
|
app.listen(PORT, () => {
|
|
|
|
|
console.log(`서버 시작: http://localhost:${PORT}`);
|
|
|
|
|
});
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('서버 시작 실패:', err);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
start();
|