Skip to content

Commit d682695

Browse files
committed
Add helper function to fix number problems
As minio causes various problem if you configure it using environment variables and leave the port setting out, which will evaluate to NaN, this change should fix this in a clean way for this time and helps to support numbers in general in future. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
1 parent 9cbe03d commit d682695

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

lib/config/environment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict'
22

3-
const {toBooleanConfig, toArrayConfig} = require('./utils')
3+
const {toBooleanConfig, toArrayConfig, toIntegerConfig} = require('./utils')
44

55
module.exports = {
66
domain: process.env.HMD_DOMAIN,
77
urlpath: process.env.HMD_URL_PATH,
8-
port: process.env.HMD_PORT,
8+
port: toIntegerConfig(process.env.HMD_PORT),
99
urladdport: toBooleanConfig(process.env.HMD_URL_ADDPORT),
1010
usessl: toBooleanConfig(process.env.HMD_USESSL),
1111
hsts: {
@@ -40,7 +40,7 @@ module.exports = {
4040
secretKey: process.env.HMD_MINIO_SECRET_KEY,
4141
endPoint: process.env.HMD_MINIO_ENDPOINT,
4242
secure: toBooleanConfig(process.env.HMD_MINIO_SECURE),
43-
port: parseInt(process.env.HMD_MINIO_PORT)
43+
port: toIntegerConfig(process.env.HMD_MINIO_PORT)
4444
},
4545
s3bucket: process.env.HMD_S3_BUCKET,
4646
facebook: {

lib/config/utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ exports.toArrayConfig = function toArrayConfig (configValue, separator = ',', fa
1313
}
1414
return fallback
1515
}
16+
17+
exports.toIntegerConfig = function toIntegerConfig (configValue) {
18+
if (configValue && typeof configValue === 'string') {
19+
return parseInt(configValue)
20+
}
21+
return configValue
22+
}

0 commit comments

Comments
 (0)