28 lines
756 B
TypeScript
28 lines
756 B
TypeScript
import { getRuntimeEnvironment } from './runtime.js';
|
|
|
|
export interface BackendControlConfig {
|
|
productId: string;
|
|
platformApiUrl: string;
|
|
tradingApiUrl: string;
|
|
backendPort: number;
|
|
corsAllowedOrigins: string[];
|
|
}
|
|
|
|
export function getBackendControlConfig(): BackendControlConfig {
|
|
const runtime = getRuntimeEnvironment('backend');
|
|
const port = Number(process.env.PORT || 4018);
|
|
const corsAllowedOrigins = String(process.env.CORS_ALLOWED_ORIGINS || '')
|
|
.split(',')
|
|
.map(value => value.trim())
|
|
.filter(Boolean);
|
|
|
|
return {
|
|
productId: runtime.productId,
|
|
platformApiUrl: runtime.platformApiUrl,
|
|
tradingApiUrl: runtime.tradingApiUrl,
|
|
backendPort: Number.isFinite(port) ? port : 4018,
|
|
corsAllowedOrigins,
|
|
};
|
|
}
|
|
|