summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorBoHong Li2017-04-13 01:57:55 +0800
committerRaccoon Li2017-05-08 19:29:07 +0800
commitecb05336055a37ba8a03c119995cd37d96aad90d (patch)
treef6815f5ce06befbe3bdb51cfd941d2c6edaf51a0 /app.js
parent4738ba7d364111adeb2eb2036d0b24d53a80c0c7 (diff)
refactor(config.js): Extract config file
* Separate different config source to each files * Freeze config object
Diffstat (limited to '')
-rw-r--r--app.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/app.js b/app.js
index 95e94b0a..3530343c 100644
--- a/app.js
+++ b/app.js
@@ -29,20 +29,17 @@ var response = require('./lib/response')
var models = require('./lib/models')
// generate front-end constants by template
-var configJson = config.raw
var constpath = path.join(__dirname, './public/js/lib/common/constant.ejs')
-var googleApiKey = (fs.existsSync('/run/secrets/google_apiKey') && config.handleDockerSecret('google_apiKey')) || process.env.HMD_GOOGLE_API_KEY || (configJson.google && configJson.google.apiKey) || ''
-var googleClientID = (fs.existsSync('/run/secrets/google_clientID') && config.handleDockerSecret('google_clientID')) || process.env.HMD_GOOGLE_CLIENT_ID || (configJson.google && configJson.google.clientID) || ''
-var dropboxAppKey = (fs.existsSync('/run/secrets/dropbox_appKey') && config.handleDockerSecret('dropbox_appKey')) || process.env.HMD_DROPBOX_APP_KEY || (configJson.dropbox && configJson.dropbox.appKey) || ''
var data = {
domain: config.domain,
urlpath: config.urlpath,
debug: config.debug,
version: config.version,
- GOOGLE_API_KEY: googleApiKey,
- GOOGLE_CLIENT_ID: googleClientID,
- DROPBOX_APP_KEY: dropboxAppKey
+ GOOGLE_API_KEY: config.google.clientSecret,
+ GOOGLE_CLIENT_ID: config.google.clientID,
+ DROPBOX_APP_KEY: config.dropbox.clientSecret
}
+
ejs.renderFile(constpath, data, {}, function (err, str) {
if (err) throw new Error(err)
fs.writeFileSync(path.join(__dirname, './public/build/constant.js'), str)
@@ -204,7 +201,7 @@ function startListen () {
server.listen(config.port, function () {
var schema = config.usessl ? 'HTTPS' : 'HTTP'
logger.info('%s Server listening at port %d', schema, config.port)
- config.maintenance = false
+ realtime.maintenance = false
})
}