maplestory/backend/routes/notices.js
caadiq 793903668c 홈 페이지 공지 위젯 + 푸터 추가
- 넥슨 공지 위젯 (이벤트/캐시샵/업데이트/공지 탭)
- 이벤트/캐시샵은 진행중인 항목 모두, 그 외는 최근 6개
- 더보기/접기 grid-template-rows 애니메이션
- 캐시샵 ongoing_flag 대신 종료일 비교 (누락 항목 수정)
- 제목/부제목 분리, 달력 이모지로 기간 표시
- 공통 푸터 (저작권, 데이터 출처)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 16:48:05 +09:00

31 lines
909 B
JavaScript

import { Router } from 'express';
import axios from 'axios';
const router = Router();
const NEXON_API_BASE = 'https://open.api.nexon.com';
const ENDPOINT_MAP = {
event: '/maplestory/v1/notice-event',
update: '/maplestory/v1/notice-update',
notice: '/maplestory/v1/notice',
cashshop: '/maplestory/v1/notice-cashshop',
};
router.get('/', async (req, res) => {
const type = req.query.type || 'event';
const endpoint = ENDPOINT_MAP[type];
if (!endpoint) return res.status(400).json({ error: '잘못된 type입니다' });
try {
const { data } = await axios.get(`${NEXON_API_BASE}${endpoint}`, {
headers: { 'x-nxopen-api-key': process.env.NEXON_API_KEY },
});
res.json(data);
} catch (err) {
console.error(`공지 조회 오류 (${type}):`, err.response?.data || err.message);
res.status(500).json({ error: '공지 조회 실패' });
}
});
export default router;