-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
config.app.js
67 lines (59 loc) · 2.12 KB
/
config.app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Copyright (c) 2014, Tidepool Project
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the associated License, which is identical to the BSD 2-Clause
* License as published by the Open Source Initiative at opensource.org.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the License for more details.
*
* You should have received a copy of the License along with this program; if
* not, you can obtain one from Tidepool Project at tidepool.org.
*/
/* global __DEV__ */
/* global __UPLOAD_API__ */
/* global __API_HOST__ */
/* global __INVITE_KEY__ */
/* global __LATEST_TERMS__ */
/* global __PASSWORD_MIN_LENGTH__ */
/* global __PASSWORD_MAX_LENGTH__ */
/* global __ABOUT_MAX_LENGTH__ */
/* global __I18N_ENABLED__ */
/* global __PENDO_ENABLED__ */
/* global __VERSION__ */
function booleanFromText(value, defaultValue) {
if (value === 'true') {
return true;
}
if (value === 'false') {
return false;
}
return (typeof value === 'boolean') ? value : defaultValue || false;
}
function integerFromText(value, defaultValue) {
value = parseInt(value, 10);
if (isNaN(value)) {
return defaultValue === undefined ? 0 : defaultValue;
}
return value;
}
const config = {
VERSION: __VERSION__,
UPLOAD_API: __UPLOAD_API__ || `${window.location.protocol}//${window.location.host}`,
API_HOST: __API_HOST__ || `${window.location.protocol}//${window.location.host}`,
INVITE_KEY: __INVITE_KEY__ || '',
LATEST_TERMS: __LATEST_TERMS__ || null,
PASSWORD_MIN_LENGTH: integerFromText(__PASSWORD_MIN_LENGTH__, 8),
PASSWORD_MAX_LENGTH: integerFromText(__PASSWORD_MAX_LENGTH__, 72),
ABOUT_MAX_LENGTH: integerFromText(__ABOUT_MAX_LENGTH__, 256),
I18N_ENABLED: booleanFromText(__I18N_ENABLED__, false),
PENDO_ENABLED: booleanFromText(__PENDO_ENABLED__, true),
}
if (__DEV__) {
window.config = config;
}
// the constants below are defined in webpack.config.js -- they're aliases for
// environment variables.
module.exports = config;