From 8786a01706a40fe28dacb287dfb065a7478e9c14 Mon Sep 17 00:00:00 2001 From: Ricardo van der Heijden <20791917+ricardovdheijden@users.noreply.github.com> Date: Mon, 3 Jun 2024 12:59:40 +0200 Subject: [PATCH] 1108 Using getEnvironmentVariables to retrieve environment variables --- configuration/configuration.ts | 74 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/configuration/configuration.ts b/configuration/configuration.ts index ec7093f..67f9db5 100644 --- a/configuration/configuration.ts +++ b/configuration/configuration.ts @@ -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', }; };