Skip to content

Commit 1a2f811

Browse files
authored
Merge pull request #1095 from opencrvs/ocrvs-10707
Remove all references and configuration to make an environment V2 from country config
2 parents a66925a + 5847398 commit 1a2f811

File tree

5 files changed

+32
-49
lines changed

5 files changed

+32
-49
lines changed

src/client-config.js

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,36 @@
1212
/**
1313
* When running application in slow network condition (reproducible using 3G), the client-config.js might be loaded twice.
1414
* This results to issues like `Uncaught SyntaxError: "identifier scheme has already been declared at (client-config.js:1:1")`.
15-
*
15+
*
1616
* On high level, refreshing the browser window requests new document page. The document page includes script tag to load client-config.js.
1717
* If the network is slow, the browser might start loading and executing client-config.js again before the previous one is torn down, causing the error.
18-
*
18+
*
1919
*/
2020
;(function initClientConfig() {
21-
22-
window.config = {
23-
API_GATEWAY_URL: 'http://localhost:7070/',
24-
CONFIG_API_URL: 'http://localhost:2021',
25-
LOGIN_URL: 'http://localhost:3020',
26-
AUTH_URL: 'http://localhost:7070/auth/',
27-
MINIO_BUCKET: 'ocrvs',
28-
MINIO_URL: 'http://localhost:3535/ocrvs/',
29-
MINIO_BASE_URL: 'http://localhost:3535', // URL without path/bucket information, used for file uploads, v2
30-
COUNTRY_CONFIG_URL: 'http://localhost:3040',
31-
// Country code in uppercase ALPHA-3 format
32-
COUNTRY: 'FAR',
33-
LANGUAGES: 'en,fr',
34-
SENTRY: '',
35-
DASHBOARDS: [
36-
{
37-
id: 'leaderboards',
38-
title: {
39-
id: 'navigation.leaderboards',
40-
defaultMessage: 'Development dashboard',
41-
description: 'Menu item for development dashboard'
42-
},
43-
url: 'http://localhost:3040/ping',
44-
}
45-
],
46-
// NOTE: This is not valid javascript until replaced during build time.
47-
// IIFE just reveals it.
48-
FEATURES: {
49-
// The V2_EVENTS variable is passed down from src/index.ts:309
50-
V2_EVENTS: {{ V2_EVENTS }}
21+
window.config = {
22+
API_GATEWAY_URL: 'http://localhost:7070/',
23+
CONFIG_API_URL: 'http://localhost:2021',
24+
LOGIN_URL: 'http://localhost:3020',
25+
AUTH_URL: 'http://localhost:7070/auth/',
26+
MINIO_BUCKET: 'ocrvs',
27+
MINIO_URL: 'http://localhost:3535/ocrvs/',
28+
MINIO_BASE_URL: 'http://localhost:3535', // URL without path/bucket information, used for file uploads, v2
29+
COUNTRY_CONFIG_URL: 'http://localhost:3040',
30+
// Country code in uppercase ALPHA-3 format
31+
COUNTRY: 'FAR',
32+
LANGUAGES: 'en,fr',
33+
SENTRY: '',
34+
DASHBOARDS: [
35+
{
36+
id: 'leaderboards',
37+
title: {
38+
id: 'navigation.leaderboards',
39+
defaultMessage: 'Development dashboard',
40+
description: 'Menu item for development dashboard'
41+
},
42+
url: 'http://localhost:3040/ping'
43+
}
44+
],
45+
FEATURES: {}
5146
}
52-
}
53-
})()
47+
})()

src/client-config.prod.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
/**
1313
* When running application in slow network condition (reproducible using 3G), the client-config.js might be loaded twice.
1414
* This results to issues like `Uncaught SyntaxError: "identifier scheme has already been declared at (client-config.js:1:1")`.
15-
*
15+
*
1616
* On high level, refreshing the browser window requests new document page. The document page includes script tag to load client-config.js.
1717
* If the network is slow, the browser might start loading and executing client-config.js again before the previous one is torn down, causing the error.
18-
*
18+
*
1919
*/
2020
;(function initClientConfig() {
2121
const scheme = window.location.protocol // "http:" or "https:"
@@ -66,9 +66,6 @@
6666
],
6767
// NOTE: This is not valid javascript until replaced during build time.
6868
// IIFE just reveals it.
69-
FEATURES: {
70-
// The V2_EVENTS variable is passed down from src/index.ts:309
71-
V2_EVENTS: {{ V2_EVENTS }}
72-
}
69+
FEATURES: {}
7370
}
7471
})()

src/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ export const CHECK_INVALID_TOKEN = env.CHECK_INVALID_TOKEN
3131

3232
export const PRODUCTION = env.isProd
3333
export const QA_ENV = env.QA_ENV
34-
export const V2_EVENTS = env.V2_EVENTS
3534
export const ANALYTICS_DATABASE_URL = env.ANALYTICS_DATABASE_URL

src/environment.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export const env = cleanEnv(process.env, {
3131
devDefault: 'http://localhost:5050/confirm/registration'
3232
}),
3333
QA_ENV: bool({ default: false }),
34-
V2_EVENTS: bool({ default: false }),
3534
ANALYTICS_DATABASE_URL: url({
3635
devDefault:
3736
'postgres://events_analytics:analytics_password@localhost:5432/events',

src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require('dotenv').config()
1313

1414
import StreamArray from 'stream-json/streamers/StreamArray'
1515
import path from 'path'
16-
import Handlebars from 'handlebars'
1716
import * as Hapi from '@hapi/hapi'
1817
import * as Pino from 'hapi-pino'
1918
import * as JWT from 'hapi-auth-jwt2'
@@ -25,7 +24,6 @@ import {
2524
DOMAIN,
2625
LOGIN_URL,
2726
SENTRY_DSN,
28-
V2_EVENTS,
2927
COUNTRY_CONFIG_HOST,
3028
COUNTRY_CONFIG_PORT,
3129
CHECK_INVALID_TOKEN,
@@ -318,11 +316,7 @@ export async function createServer() {
318316
? '/client-config.prod.js'
319317
: '/client-config.js'
320318

321-
const template = Handlebars.compile(
322-
readFileSync(join(__dirname, file), 'utf8')
323-
)
324-
const result = template({ V2_EVENTS })
325-
return h.response(result).type('application/javascript')
319+
return h.file(join(__dirname, file))
326320
},
327321
options: {
328322
auth: false,

0 commit comments

Comments
 (0)