Project

General

Profile

Feature #10306 » env.ts

Thirupathirao Uppu, 08/10/2026 11:35 AM

 
/**
* Application environment — white-label aware.
*
* Values come from react-native-config (.env) + tenants/<id>/config.json
* via `src/config/tenant.ts`. Do not hardcode client URLs here.
*
* Switch tenant:
* npm run tenant:switch -- regal-solar
* npm run tenant:switch -- demo-brand
*/

import Config from 'react-native-config';
import { tenant } from './tenant';

function resolveNodeEnv(): 'development' | 'production' | 'test' {
const fromConfig = Config.NODE_ENV;
if (fromConfig === 'production' || fromConfig === 'test' || fromConfig === 'development') {
return fromConfig;
}
return __DEV__ ? 'development' : 'production';
}

/** REST API base (includes /api suffix when configured that way) */
export const REACT_NATIVE_APP_API_URL: string = tenant.api.baseUrl;

/** Socket.io origin (no /api path) */
export const REACT_NATIVE_APP_SOCKET_URL: string = tenant.api.socketUrl;

/** HTTP timeout for long operations (e.g. PDF extract) */
export const API_TIMEOUT_MS: number = tenant.api.timeoutMs;

export const NODE_ENV = resolveNodeEnv();

export const APP_TENANT = tenant.tenantId;
export const APP_DISPLAY_NAME = tenant.displayName;
(2-2/5)