summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/config/environment.js15
-rw-r--r--lib/config/oldEnvironment.js4
-rw-r--r--lib/config/utils.js8
3 files changed, 20 insertions, 7 deletions
diff --git a/lib/config/environment.js b/lib/config/environment.js
index cd0c0097..75381ffc 100644
--- a/lib/config/environment.js
+++ b/lib/config/environment.js
@@ -1,15 +1,18 @@
'use strict'
+const {toBooleanConfig} = require('./utils')
+
module.exports = {
domain: process.env.HMD_DOMAIN,
urlpath: process.env.HMD_URL_PATH,
port: process.env.HMD_PORT,
urladdport: process.env.HMD_URL_ADDPORT,
- usessl: (process.env.HMD_PROTOCOL_USESSL === 'true'),
+ usessl: toBooleanConfig(process.env.HMD_USESSL),
+ protocolusessl: toBooleanConfig(process.env.HMD_PROTOCOL_USESSL),
alloworigin: process.env.HMD_ALLOW_ORIGIN ? process.env.HMD_ALLOW_ORIGIN.split(',') : undefined,
- usecdn: (process.env.HMD_USECDN === 'true'),
- allowanonymous: (process.env.HMD_ALLOW_ANONYMOUS === 'true'),
- allowfreeurl: (process.env.HMD_ALLOW_FREEURL === 'true'),
+ usecdn: toBooleanConfig(process.env.HMD_USECDN),
+ allowanonymous: toBooleanConfig(process.env.HMD_ALLOW_ANONYMOUS),
+ allowfreeurl: toBooleanConfig(process.env.HMD_ALLOW_FREEURL),
defaultpermission: process.env.HMD_DEFAULT_PERMISSION,
dburl: process.env.HMD_DB_URL,
imageUploadType: process.env.HMD_IMAGE_UPLOAD_TYPE,
@@ -59,6 +62,6 @@ module.exports = {
searchAttributes: process.env.HMD_LDAP_SEARCHATTRIBUTES,
tlsca: process.env.HMD_LDAP_TLS_CA
},
- email: (process.env.HMD_EMAIL === 'true'),
- allowemailregister: (process.env.HMD_ALLOW_EMAIL_REGISTER === 'true')
+ email: toBooleanConfig(process.env.HMD_EMAIL),
+ allowemailregister: toBooleanConfig(process.env.HMD_ALLOW_EMAIL_REGISTER)
}
diff --git a/lib/config/oldEnvironment.js b/lib/config/oldEnvironment.js
index 67e70ff0..a3b13cb9 100644
--- a/lib/config/oldEnvironment.js
+++ b/lib/config/oldEnvironment.js
@@ -1,7 +1,9 @@
'use strict'
+const {toBooleanConfig} = require('./utils')
+
module.exports = {
- debug: (process.env.DEBUG === 'true'),
+ debug: toBooleanConfig(process.env.DEBUG),
dburl: process.env.DATABASE_URL,
urlpath: process.env.URL_PATH,
port: process.env.PORT
diff --git a/lib/config/utils.js b/lib/config/utils.js
new file mode 100644
index 00000000..11bbd8cb
--- /dev/null
+++ b/lib/config/utils.js
@@ -0,0 +1,8 @@
+'use strict'
+
+exports.toBooleanConfig = function toBooleanConfig (configValue) {
+ if (configValue && typeof configValue === 'string') {
+ return (configValue === 'true')
+ }
+ return configValue
+}