- 백엔드: notices/character 라우트에서 OPENAPI00001/00007/00010/00011
응답을 감지해 503 + { maintenance: true, code } 반환
- 프론트 api 클라이언트가 에러에 서버 필드(maintenance 등)를 병합
- 공지 위젯: 점검중이면 "넥슨 Open API 점검중" 안내 + retry 차단
- 캐릭터 검색 오류 메시지로 '점검중' 상황이 "존재하지 않는 캐릭터"와 구분
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
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) {
|
|
const errData = err.response?.data?.error;
|
|
const code = errData?.name;
|
|
// Nexon 점검 코드: OPENAPI00001(게임 점검), OPENAPI00007(api 점검), OPENAPI00011(오픈 API 점검)
|
|
const underMaintenance = ['OPENAPI00001', 'OPENAPI00007', 'OPENAPI00010', 'OPENAPI00011'].includes(code);
|
|
if (underMaintenance) {
|
|
return res.status(503).json({ error: 'API 점검중입니다', code, maintenance: true });
|
|
}
|
|
console.error(`공지 조회 오류 (${type}):`, err.response?.data || err.message);
|
|
res.status(500).json({ error: '공지 조회 실패' });
|
|
}
|
|
});
|
|
|
|
export default router;
|