From 168945c8fdb0a77f3636c7ed8f959bfa757796e5 Mon Sep 17 00:00:00 2001 From: Ilya Beda Date: Thu, 8 Aug 2024 12:39:10 +1000 Subject: [PATCH] Better configuration --- shared/src/constants.ts | 28 +++++++++++++++------------- web/public/docker_entrypoint.sh | 10 +++++++--- web/public/index.html | 5 ++++- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/shared/src/constants.ts b/shared/src/constants.ts index da1d5bc0..556cc037 100644 --- a/shared/src/constants.ts +++ b/shared/src/constants.ts @@ -1,14 +1,16 @@ -export const baseURL = - (window as any).BASE_URL === '{{BASE_URL}}' - ? 'http://localhost:8080/' - : (window as any).BASE_URL; -export const juteURL = - (window as any).JUTE_URL === '{{JUTE_URL}}' - ? 'http://localhost:8099/' - : (window as any).JUTE_URL; +function getConfig(key: string, defaultValue: string) { + const value = (window as any)[key]; + if (value === '{{' + key + '}}' || value === null || value === undefined) { + return defaultValue; + } + return value; +} -export const aiQuestionnaireBuilderUrl = 'https://builder.emr.beda.software'; -// export const aiQuestionnaireBuilderUrl = 'http://localhost:3002'; -export const fhirpathMappingUrl = 'https://fhirpathmapper.emr.beda.software'; -// export const fhirpathMappingUrl = 'http://localhost:8091'; -export const fhirMappingLanguageUrl = 'http://localhost:8084/matchboxv3/fhir' +export const baseURL = getConfig('BASE_URL', 'http://localhost:8080'); +export const juteURL = getConfig('JUTE_URL', 'http://localhost:8099'); +export const aiQuestionnaireBuilderUrl = getConfig('AI_BUILDER_URL', 'http://localhost:3002'); +export const fhirMappingLanguageUrl = getConfig( + 'FHIR_MAPPING_LANGUAGE_URL', + 'http://localhost:8084/matchboxv3/fhir', +); +export const fhirpathMappingUrl = getConfig('FHIRPATH_MAPPING_URL', 'http://localhost:8091'); diff --git a/web/public/docker_entrypoint.sh b/web/public/docker_entrypoint.sh index d780e5ed..2d9bdf70 100755 --- a/web/public/docker_entrypoint.sh +++ b/web/public/docker_entrypoint.sh @@ -1,6 +1,10 @@ #!/bin/sh -e -sed s/{{BASE_URL}}/$BASE_URL/g index.html > index2.html -sed s/{{JUTE_URL}}/$JUTE_URL/g index2.html > index3.html -mv index3.html index.html +sed -i \ + -e s/{{BASE_URL}}/$BASE_URL/g \ + -e s/{{JUTE_URL}}/$JUTE_URL/g \ + -e s/{{AI_BUILDER_URL}}/$AI_BUILDER_URL/g \ + -e s/{{FHIR_MAPPING_LANGUAGE_URL}}/$FHIR_MAPPING_LANGUAGE_URL/g \ + -e s/{{FHIRPATH_MAPPING_URL}}/$FHIRPATH_MAPPING_URL/g \ + index.html serve -n -s -l tcp://0.0.0.0:5000 diff --git a/web/public/index.html b/web/public/index.html index c3328850..f51f64a7 100644 --- a/web/public/index.html +++ b/web/public/index.html @@ -5,6 +5,9 @@ @@ -36,4 +39,4 @@ To create a production bundle, use `npm run build` or `yarn build`. --> - \ No newline at end of file +