import { api } from './api'; import type { VesselPosition, MapBounds } from '@common/types/vessel'; export async function getVesselsInArea(bounds: MapBounds): Promise { const res = await api.post('/vessels/in-area', { bounds }); return res.data; } /** * 로그인/새로고침 직후 1회 호출하는 초기 스냅샷 API. * 운영 환경의 별도 REST 서버가 현재 시각 기준 최근 10분치 선박 신호를 반환한다. * URL은 VITE_VESSEL_INIT_API_URL 로 주입(운영에서 실제 URL로 교체). */ export async function getInitialVesselSnapshot(): Promise { 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 { const res = await api.get('/vessels/status'); return res.data; }