wing-ops/frontend/src/common/services/vesselApi.ts
jeonghyo.k 29c5293ce7 feat(vessels): 실시간 선박 신호 지도 표출 및 폴링 스케줄러 추가
- 백엔드 vessels 라우터/서비스/스케줄러 추가 (1분 주기 한국 해역 폴링)
- 공통 useVesselSignals 훅 + vesselApi/vesselSignalClient 서비스 추가
- MapView에 VesselLayer/VesselInteraction/MapBoundsTracker 통합 (호버·팝업·상세 모달)
- OilSpill/HNS/Rescue/Incidents 뷰에 선박 신호 연동
- vesselMockData 정리, aerial IMAGE_API_URL 기본값 변경
2026-04-15 14:40:28 +09:00

36 lines
1.3 KiB
TypeScript

import { api } from './api';
import type { VesselPosition, MapBounds } from '@common/types/vessel';
export async function getVesselsInArea(bounds: MapBounds): Promise<VesselPosition[]> {
const res = await api.post<VesselPosition[]>('/vessels/in-area', { bounds });
return res.data;
}
/**
* 로그인/새로고침 직후 1회 호출하는 초기 스냅샷 API.
* 운영 환경의 별도 REST 서버가 현재 시각 기준 최근 10분치 선박 신호를 반환한다.
* URL은 VITE_VESSEL_INIT_API_URL 로 주입(운영에서 실제 URL로 교체).
*/
export async function getInitialVesselSnapshot(): Promise<VesselPosition[]> {
const url = import.meta.env.VITE_VESSEL_INIT_API_URL as string | undefined;
if (!url) return [];
const res = await fetch(url, { method: 'GET' });
if (!res.ok) throw new Error(`vessel init snapshot ${res.status}`);
return (await res.json()) as VesselPosition[];
}
export function isVesselInitEnabled(): boolean {
return import.meta.env.VITE_VESSEL_INIT_ENABLED === 'true';
}
export interface VesselCacheStatus {
count: number;
bangjeCount: number;
lastUpdated: string | null;
}
export async function getVesselCacheStatus(): Promise<VesselCacheStatus> {
const res = await api.get<VesselCacheStatus>('/vessels/status');
return res.data;
}