@boomerang-io/webapp-spa-server 1.0.0-beta.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +20 -8
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -38,6 +38,7 @@ function createBoomerangServer({
|
|
|
38
38
|
BUILD_DIR = "build",
|
|
39
39
|
BASE_LAUNCH_ENV_URL,
|
|
40
40
|
GA_SITE_ID,
|
|
41
|
+
ENABLE_BEEHEARD_SURVEY,
|
|
41
42
|
} = process.env;
|
|
42
43
|
logger.debug("PROCESS ENV: ", process.env);
|
|
43
44
|
|
|
@@ -61,9 +62,11 @@ function createBoomerangServer({
|
|
|
61
62
|
|
|
62
63
|
// Security
|
|
63
64
|
const helmet = require("helmet");
|
|
64
|
-
app.use(
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
app.use(
|
|
66
|
+
helmet({
|
|
67
|
+
contentSecurityPolicy: false,
|
|
68
|
+
})
|
|
69
|
+
);
|
|
67
70
|
app.disable("x-powered-by");
|
|
68
71
|
app.use(cors(corsConfig));
|
|
69
72
|
|
|
@@ -87,7 +90,7 @@ function createBoomerangServer({
|
|
|
87
90
|
*/
|
|
88
91
|
logger.debug("0 - disableInjectHTMLHeadData: ", disableInjectHTMLHeadData);
|
|
89
92
|
if (!disableInjectHTMLHeadData) {
|
|
90
|
-
logger.debug("1 - URL and ID: ",GA_SITE_ID,BASE_LAUNCH_ENV_URL);
|
|
93
|
+
logger.debug("1 - URL and ID: ", GA_SITE_ID, BASE_LAUNCH_ENV_URL);
|
|
91
94
|
appRouter.use(
|
|
92
95
|
"/",
|
|
93
96
|
express.static(path.join(process.cwd(), BUILD_DIR), {
|
|
@@ -102,11 +105,12 @@ function createBoomerangServer({
|
|
|
102
105
|
HTML_HEAD_INJECTED_SCRIPTS,
|
|
103
106
|
APP_ROOT,
|
|
104
107
|
GA_SITE_ID,
|
|
105
|
-
BASE_LAUNCH_ENV_URL
|
|
108
|
+
BASE_LAUNCH_ENV_URL,
|
|
109
|
+
ENABLE_BEEHEARD_SURVEY
|
|
106
110
|
)
|
|
107
111
|
);
|
|
108
112
|
} else {
|
|
109
|
-
logger.debug("1 - disableInjectHTMLHeadData: ",disableInjectHTMLHeadData);
|
|
113
|
+
logger.debug("1 - disableInjectHTMLHeadData: ", disableInjectHTMLHeadData);
|
|
110
114
|
appRouter.use("/", express.static(path.join(process.cwd(), BUILD_DIR)));
|
|
111
115
|
}
|
|
112
116
|
|
|
@@ -138,6 +142,7 @@ function createBoomerangServer({
|
|
|
138
142
|
* @param {string} appRoot - root context off app. Used for script injection
|
|
139
143
|
* @param {string} gaSiteId - siteID to be injected on scripts to support GA
|
|
140
144
|
* @param {string} baseLaunchUrl - base url to determine GA primaryCategory
|
|
145
|
+
* @param {boolean} enableBeeheardSurvey - true/false value configured at helm to decide to insert survey script
|
|
141
146
|
*/
|
|
142
147
|
function injectEnvDataAndScriptsIntoHTML(
|
|
143
148
|
res,
|
|
@@ -146,13 +151,14 @@ function injectEnvDataAndScriptsIntoHTML(
|
|
|
146
151
|
injectedScripts,
|
|
147
152
|
appRoot,
|
|
148
153
|
gaSiteId,
|
|
149
|
-
baseLaunchUrl
|
|
154
|
+
baseLaunchUrl,
|
|
155
|
+
enableBeeheardSurvey
|
|
150
156
|
) {
|
|
151
157
|
/**
|
|
152
158
|
* Create objects to be injected into application via the HEAD tag
|
|
153
159
|
*/
|
|
154
160
|
// Build script for GA integration
|
|
155
|
-
logger.debug("2 - GA Site ID: ",gaSiteId);
|
|
161
|
+
logger.debug("2 - GA Site ID: ", gaSiteId);
|
|
156
162
|
const headScripstGA = Boolean(gaSiteId)
|
|
157
163
|
? `<script type="text/javascript">
|
|
158
164
|
window.idaPageIsSPA = true;
|
|
@@ -182,6 +188,11 @@ function injectEnvDataAndScriptsIntoHTML(
|
|
|
182
188
|
<script src="//1.www.s81c.com/common/stats/ibm-common.js" type="text/javascript"></script>
|
|
183
189
|
`
|
|
184
190
|
: "";
|
|
191
|
+
|
|
192
|
+
const headScriptBeeheardSurvey = Boolean(enableBeeheardSurvey)
|
|
193
|
+
? '<script async src="https://beeheard.dal1a.cirrus.ibm.com/survey/preconfig/HHPxpQgN.js"></script>'
|
|
194
|
+
: "";
|
|
195
|
+
|
|
185
196
|
// Build up object of external data to append
|
|
186
197
|
const headInjectedData = injectedDataKeys.split(",").reduce((acc, key) => {
|
|
187
198
|
acc[key] = process.env[key];
|
|
@@ -221,6 +232,7 @@ function injectEnvDataAndScriptsIntoHTML(
|
|
|
221
232
|
isJSON: true,
|
|
222
233
|
})};
|
|
223
234
|
</script>
|
|
235
|
+
${headScriptBeeheardSurvey}
|
|
224
236
|
${headScripstGA}
|
|
225
237
|
${headScriptsTags}
|
|
226
238
|
</head>`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boomerang-io/webapp-spa-server",
|
|
3
3
|
"description": "Webapp Server for React-based SPA w/ client-side routing",
|
|
4
|
-
"version": "1.0.0
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Tim Bula",
|
|
7
7
|
"email": "timrbula@gmail.com"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"start": "node tester.js"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@boomerang-io/logger-middleware": "
|
|
28
|
+
"@boomerang-io/logger-middleware": "1.0.0",
|
|
29
29
|
"@cloudnative/health-connect": "^2.1.0",
|
|
30
30
|
"body-parser": "^1.19.1",
|
|
31
31
|
"compression": "^1.7.4",
|