- 백엔드 vessels 라우터/서비스/스케줄러 추가 (1분 주기 한국 해역 폴링) - 공통 useVesselSignals 훅 + vesselApi/vesselSignalClient 서비스 추가 - MapView에 VesselLayer/VesselInteraction/MapBoundsTracker 통합 (호버·팝업·상세 모달) - OilSpill/HNS/Rescue/Incidents 뷰에 선박 신호 연동 - vesselMockData 정리, aerial IMAGE_API_URL 기본값 변경
34 lines
979 B
TypeScript
34 lines
979 B
TypeScript
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;
|