Files
planet/frontend/src/services/situational-awareness/index.ts
2026-04-07 17:30:27 +08:00

24 lines
793 B
TypeScript

import type { SituationalAwarenessGateway } from './port'
import { HttpSituationalAwarenessGateway } from './http-gateway'
import { MockSituationalAwarenessGateway } from './mock-gateway'
export * from './types'
export type { SituationalAwarenessGateway } from './port'
let singleton: SituationalAwarenessGateway | null = null
export function createSituationalAwarenessGateway(): SituationalAwarenessGateway {
const provider = (import.meta as any).env?.VITE_SA_GATEWAY || 'http'
if (provider === 'mock') {
return new MockSituationalAwarenessGateway()
}
return new HttpSituationalAwarenessGateway()
}
export function getSituationalAwarenessGateway(): SituationalAwarenessGateway {
if (!singleton) {
singleton = createSituationalAwarenessGateway()
}
return singleton
}