Skip to content

Commit e2b8b92

Browse files
authored
Merge pull request #769 from SISheogorath/fix/minioInteger
Add helper function to fix number problems
2 parents 9cbe03d + d682695 commit e2b8b92

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)