Skip to content

Commit dde6e62

Browse files
committed
Fix front-end constants generation not getting config properly
1 parent 7e3b74d commit dde6e62

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

app.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,19 @@ var response = require('./lib/response.js')
3030
var models = require('./lib/models')
3131

3232
// generate front-end constants by template
33+
var configJson = config.raw
3334
var constpath = path.join(__dirname, './public/js/lib/common/constant.ejs')
35+
var googleApiKey = (fs.existsSync('/run/secrets/google_apiKey') && config.handleDockerSecret('google_apiKey')) || process.env.HMD_GOOGLE_API_KEY || (configJson.google && configJson.google.apiKey) || ''
36+
var googleClientID = (fs.existsSync('/run/secrets/google_clientID') && config.handleDockerSecret('google_clientID')) || process.env.HMD_GOOGLE_CLIENT_ID || (configJson.google && configJson.google.clientID) || ''
37+
var dropboxAppKey = (fs.existsSync('/run/secrets/dropbox_appKey') && config.handleDockerSecret('dropbox_appKey')) || process.env.HMD_DROPBOX_APP_KEY || (configJson.dropbox && configJson.dropbox.appKey) || ''
3438
var data = {
3539
domain: config.domain,
3640
urlpath: config.urlpath,
3741
debug: config.debug,
3842
version: config.version,
39-
GOOGLE_API_KEY: config.google ? config.google.GOOGLE_API_KEY : '',
40-
GOOGLE_CLIENT_ID: config.google ? config.google.GOOGLE_CLIENT_ID : '',
41-
DROPBOX_APP_KEY: config.dropbox ? config.dropbox.DROPBOX_APP_KEY : ''
43+
GOOGLE_API_KEY: googleApiKey,
44+
GOOGLE_CLIENT_ID: googleClientID,
45+
DROPBOX_APP_KEY: dropboxAppKey
4246
}
4347
ejs.renderFile(constpath, data, {}, function (err, str) {
4448
if (err) throw new Error(err)

app.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
"description": "Dropbox API client secret",
102102
"required": false
103103
},
104+
"HMD_DROPBOX_APP_KEY": {
105+
"description": "Dropbox app key (for import/export)",
106+
"required": false
107+
},
104108
"HMD_GOOGLE_CLIENTID": {
105109
"description": "Google API client id",
106110
"required": false
@@ -109,6 +113,10 @@
109113
"description": "Google API client secret",
110114
"required": false
111115
},
116+
"HMD_GOOGLE_API_KEY": {
117+
"description": "Google API key (for import/export)",
118+
"required": false
119+
},
112120
"HMD_IMGUR_CLIENTID": {
113121
"description": "Imgur API client id",
114122
"required": false

lib/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ var maintenance = true
170170
var cwd = path.join(__dirname, '..')
171171

172172
module.exports = {
173+
raw: config,
174+
handleDockerSecret: handleDockerSecret,
173175
version: version,
174176
minimumCompatibleVersion: minimumCompatibleVersion,
175177
maintenance: maintenance,

0 commit comments

Comments
 (0)