- sequelize 모델: sunday_maple (week_start/variant/image_url 등)
- services/sundayMaple.js: 이벤트 API 조회 + HTML 스크래핑 + rustfs 업로드 + DB 저장 공용 함수
- services/sundayMapleCron.js: 금요일 09:00 KST에 10초 간격 폴링 (최대 5분)
- routes/sunday-maple.js: GET /api/sunday-maple/current
* 금/토/일만 available
* DB 없으면 lazy fetch 시도 (cron miss 대비)
- 제목 파싱으로 normal/special variant 판별
- rustfs 경로: maplestory/sunday/{week_start}.png
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
import express from 'express';
|
|
import cors from 'cors';
|
|
import adminRoutes from './routes/admin.js';
|
|
import menuRoutes from './routes/menus.js';
|
|
import noticeRoutes from './routes/notices.js';
|
|
import bossCrystalRoutes from './routes/boss-crystal.js';
|
|
import characterRoutes from './routes/character.js';
|
|
import imageRoutes from './routes/images.js';
|
|
import symbolRoutes from './routes/symbol.js';
|
|
import sundayMapleRoutes from './routes/sunday-maple.js';
|
|
import { sequelize } from './lib/db.js';
|
|
import './models/index.js';
|
|
import { scheduleSundayMapleCron } from './services/sundayMapleCron.js';
|
|
|
|
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());
|
|
|
|
app.use('/api/menus', menuRoutes);
|
|
app.use('/api/notices', noticeRoutes);
|
|
app.use('/api/boss-crystal', bossCrystalRoutes);
|
|
app.use('/api/character', characterRoutes);
|
|
app.use('/api/images', imageRoutes);
|
|
app.use('/api/symbols', symbolRoutes);
|
|
app.use('/api/sunday-maple', sundayMapleRoutes);
|
|
app.use('/api/admin', adminRoutes);
|
|
|
|
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('테이블 동기화 완료');
|
|
|
|
scheduleSundayMapleCron();
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`서버 시작: http://localhost:${PORT}`);
|
|
});
|
|
} catch (err) {
|
|
console.error('서버 시작 실패:', err);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
start();
|