24 lines
793 B
TypeScript
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
|
|
}
|