import { Router } from 'express'; import { getVesselsInBounds, getCacheStatus } from './vesselService.js'; import type { BoundingBox } from './vesselTypes.js'; const vesselRouter = Router(); // POST /api/vessels/in-area // 현재 뷰포트 bbox 안의 선박 목록 반환 (메모리 캐시에서 필터링) vesselRouter.post('/in-area', (req, res) => { const { bounds } = req.body as { bounds?: BoundingBox }; if ( !bounds || typeof bounds.minLon !== 'number' || typeof bounds.minLat !== 'number' || typeof bounds.maxLon !== 'number' || typeof bounds.maxLat !== 'number' ) { res.status(400).json({ error: '유효한 bounds 정보가 필요합니다.' }); return; } const vessels = getVesselsInBounds(bounds); res.json(vessels); }); // GET /api/vessels/status — 캐시 상태 확인 (디버그용) vesselRouter.get('/status', (_req, res) => { const status = getCacheStatus(); res.json(status); }); export default vesselRouter;