-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1108 Using getEnvironmentVariables to retrieve environment variables
- Loading branch information
1 parent
49262ad
commit 8786a01
Showing
1 changed file
with
36 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,49 @@ | ||
import process from 'process'; | ||
|
||
import { | ||
Environment, | ||
OrchestratorConfig, | ||
getEnvironmentVariables, | ||
} from '@orchestrator-ui/orchestrator-ui-components'; | ||
|
||
export const DEFAULT_GRAPHQL_CORE_ENDPOINT = | ||
'http://localhost:8080/api/graphql'; | ||
export const DEFAULT_ORCHESTRATOR_API_BASE_URL = 'http://localhost:8080/api'; | ||
export const DEFAULT_ORCHESTRATOR_WEBSOCKET_URL = 'ws://localhost:8080'; | ||
|
||
export const ENGINE_STATUS_ENDPOINT = '/settings/status'; | ||
export const PROCESS_STATUS_COUNTS_ENDPOINT = '/processes/status-counts'; | ||
export const PROCESSES_ENDPOINT = '/processes'; | ||
export const SUBSCRIPTION_ACTIONS_ENDPOINT = '/subscriptions/workflows'; | ||
export const SUBSCRIPTION_PROCESSES_ENDPOINT = | ||
'/processes/process-subscriptions-by-subscription-id'; | ||
export const DEFAULT_WORKFLOW_INFORMATION_LINK_URL = 'http://localhost:8080'; | ||
|
||
export const getInitialOrchestratorConfig = (): OrchestratorConfig => { | ||
const orchestratorGraphqlBaseUrl = | ||
process.env.ORCHESTRATOR_GRAPHQL_HOST && | ||
process.env.ORCHESTRATOR_GRAPHQL_PATH | ||
? `${process.env.ORCHESTRATOR_GRAPHQL_HOST}${process.env.ORCHESTRATOR_GRAPHQL_PATH}` | ||
: DEFAULT_GRAPHQL_CORE_ENDPOINT; | ||
const { | ||
USE_THEME_TOGGLE, | ||
ENVIRONMENT_NAME, | ||
ORCHESTRATOR_API_HOST, | ||
ORCHESTRATOR_API_PATH, | ||
ORCHESTRATOR_GRAPHQL_HOST, | ||
ORCHESTRATOR_GRAPHQL_PATH, | ||
ORCHESTRATOR_WEBSOCKET_URL, | ||
USE_WEB_SOCKETS, | ||
WORKFLOW_INFORMATION_LINK_URL, | ||
SHOW_WORKFLOW_INFORMATION_LINK, | ||
OAUTH2_ACTIVE, | ||
} = getEnvironmentVariables([ | ||
'USE_THEME_TOGGLE', | ||
'ENVIRONMENT_NAME', | ||
'ORCHESTRATOR_API_HOST', | ||
'ORCHESTRATOR_API_PATH', | ||
'ORCHESTRATOR_GRAPHQL_HOST', | ||
'ORCHESTRATOR_GRAPHQL_PATH', | ||
'ORCHESTRATOR_WEBSOCKET_URL', | ||
'USE_WEB_SOCKETS', | ||
'WORKFLOW_INFORMATION_LINK_URL', | ||
'SHOW_WORKFLOW_INFORMATION_LINK', | ||
'OAUTH2_ACTIVE', | ||
]); | ||
|
||
const orchestratorApiBaseUrl = | ||
process.env.ORCHESTRATOR_API_HOST && process.env.ORCHESTRATOR_API_PATH | ||
? `${process.env.ORCHESTRATOR_API_HOST}${process.env.ORCHESTRATOR_API_PATH}` | ||
: DEFAULT_ORCHESTRATOR_API_BASE_URL; | ||
const graphqlEndpointCore = `${ORCHESTRATOR_GRAPHQL_HOST}${ORCHESTRATOR_GRAPHQL_PATH}`; | ||
const orchestratorApiBaseUrl = `${ORCHESTRATOR_API_HOST}${ORCHESTRATOR_API_PATH}`; | ||
|
||
return { | ||
orchestratorApiBaseUrl, | ||
graphqlEndpointCore: orchestratorGraphqlBaseUrl, | ||
environmentName: | ||
process.env.ENVIRONMENT_NAME ?? Environment.DEVELOPMENT, | ||
orchestratorWebsocketUrl: | ||
process.env.ORCHESTRATOR_WEBSOCKET_URL || | ||
DEFAULT_ORCHESTRATOR_WEBSOCKET_URL, | ||
authActive: process.env.AUTH_ACTIVE?.toLowerCase() != 'false', | ||
useWebSockets: process.env.USE_WEB_SOCKETS?.toLowerCase() === 'true', | ||
useThemeToggle: process.env.USE_THEME_TOGGLE?.toLowerCase() === 'true', | ||
workflowInformationLinkUrl: | ||
process.env.WORKFLOW_INFORMATION_LINK_URL ?? | ||
DEFAULT_WORKFLOW_INFORMATION_LINK_URL, | ||
graphqlEndpointCore, | ||
environmentName: ENVIRONMENT_NAME ?? Environment.DEVELOPMENT, | ||
orchestratorWebsocketUrl: ORCHESTRATOR_WEBSOCKET_URL, | ||
authActive: OAUTH2_ACTIVE?.toLowerCase() != 'false', | ||
useWebSockets: USE_WEB_SOCKETS?.toLowerCase() === 'true', | ||
useThemeToggle: USE_THEME_TOGGLE?.toLowerCase() === 'true', | ||
workflowInformationLinkUrl: WORKFLOW_INFORMATION_LINK_URL, | ||
showWorkflowInformationLink: | ||
process.env.SHOW_WORKFLOW_INFORMATION_LINK?.toLowerCase() === | ||
'true', | ||
SHOW_WORKFLOW_INFORMATION_LINK?.toLowerCase() === 'true', | ||
}; | ||
}; |