summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/config.js48
1 files changed, 34 insertions, 14 deletions
diff --git a/lib/config.js b/lib/config.js
index 588128a7..46afea9e 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -7,16 +7,17 @@ var config = require(path.join(__dirname, '..', 'config.json'))[env];
var debug = process.env.DEBUG ? (process.env.DEBUG === 'true') : ((typeof config.debug === 'boolean') ? config.debug : (env === 'development'));
// url
-var domain = process.env.DOMAIN || config.domain || '';
-var urlpath = process.env.URL_PATH || config.urlpath || '';
-var port = process.env.PORT || config.port || 3000;
-var alloworigin = config.alloworigin || ['localhost'];
+var domain = process.env.DOMAIN || process.env.HMD_DOMAIN || config.domain || '';
+var urlpath = process.env.URL_PATH || process.env.HMD_URL_PATH || config.urlpath || '';
+var port = process.env.PORT || process.env.HMD_PORT || config.port || 3000;
+var alloworigin = process.env.HMD_ALLOW_ORIGIN ? process.env.HMD_ALLOW_ORIGIN.split(',') : (config.alloworigin || ['localhost']);
var usessl = !!config.usessl;
-var protocolusessl = (config.usessl === true && typeof config.protocolusessl === 'undefined') ? true : !!config.protocolusessl;
-var urladdport = !!config.urladdport;
+var protocolusessl = (usessl === true && typeof process.env.HMD_PROTOCOL_USESSL === 'undefined' && typeof config.protocolusessl === 'undefined')
+ ? true : (process.env.HMD_PROTOCOL_USESSL ? (process.env.HMD_PROTOCOL_USESSL === 'true') : !!config.protocolusessl);
+var urladdport = process.env.HMD_URL_ADDPORT ? (process.env.HMD_URL_ADDPORT === 'true') : !!config.urladdport;
-var usecdn = !!config.usecdn;
+var usecdn = process.env.HMD_USECDN ? (process.env.HMD_USECDN === 'true') : !!config.usecdn;
// db
var db = config.db || {
@@ -56,13 +57,32 @@ var heartbeattimeout = config.heartbeattimeout || 5000;
var documentmaxlength = config.documentmaxlength || 100000;
// auth
-var facebook = config.facebook || false;
-var twitter = config.twitter || false;
-var github = config.github || false;
-var gitlab = config.gitlab || false;
-var dropbox = config.dropbox || false;
-var google = config.google || false;
-var imgur = config.imgur || false;
+var facebook = (process.env.HMD_FACEBOOK_CLIENTID && process.env.HMD_FACEBOOK_CLIENTSECRET) ? {
+ clientID: process.env.HMD_FACEBOOK_CLIENTID,
+ clientSecret: process.env.HMD_FACEBOOK_CLIENTSECRET
+} : config.facebook || false;
+var twitter = (process.env.HMD_TWITTER_CONSUMERKEY && process.env.HMD_TWITTER_CONSUMERSECRET) ? {
+ consumerKey: process.env.HMD_TWITTER_CONSUMERKEY,
+ consumerSecret: process.env.HMD_TWITTER_CONSUMERSECRET
+} : config.twitter || false;
+var github = (process.env.HMD_GITHUB_CLIENTID && process.env.HMD_GITHUB_CLIENTSECRET) ? {
+ clientID: process.env.HMD_GITHUB_CLIENTID,
+ clientSecret: process.env.HMD_GITHUB_CLIENTSECRET
+} : config.github || false;
+var gitlab = (process.env.HMD_GITLAB_CLIENTID && process.env.HMD_GITLAB_CLIENTSECRET) ? {
+ baseURL: process.env.HMD_GITLAB_BASEURL,
+ clientID: process.env.HMD_GITLAB_CLIENTID,
+ clientSecret: process.env.HMD_GITLAB_CLIENTSECRET
+} : config.gitlab || false;
+var dropbox = (process.env.HMD_DROPBOX_CLIENTID && process.env.HMD_DROPBOX_CLIENTSECRET) ? {
+ clientID: process.env.HMD_DROPBOX_CLIENTID,
+ clientSecret: process.env.HMD_DROPBOX_CLIENTSECRET
+} : config.dropbox || false;
+var google = (process.env.HMD_GOOGLE_CLIENTID && process.env.HMD_GOOGLE_CLIENTSECRET) ? {
+ clientID: process.env.HMD_GOOGLE_CLIENTID,
+ clientSecret: process.env.HMD_GOOGLE_CLIENTSECRET
+} : config.google || false;
+var imgur = process.env.HMD_IMGUR_CLIENTID || config.imgur || false;
function getserverurl() {
var url = '';