Skip to content

Commit

Permalink
1108 Using getEnvironmentVariables to retrieve environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardovdheijden committed Jun 3, 2024
1 parent 387169d commit 35cb01a
Showing 1 changed file with 36 additions and 38 deletions.
74 changes: 36 additions & 38 deletions configuration/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
import process from 'process';

import {
Environment,
OrchestratorConfig,
getEnvironmentVariables,

Check failure on line 4 in configuration/configuration.ts

View workflow job for this annotation

GitHub Actions / tsc-and-linting

Module '"@orchestrator-ui/orchestrator-ui-components"' has no exported member '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',
};
};

0 comments on commit 35cb01a

Please sign in to comment.