summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/config.js7
-rw-r--r--lib/models/index.js8
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/config.js b/lib/config.js
index 9e8aa337..f8df0a73 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -24,10 +24,8 @@ var allowanonymous = process.env.HMD_ALLOW_ANONYMOUS ? (process.env.HMD_ALLOW_AN
var allowfreeurl = process.env.HMD_ALLOW_FREEURL ? (process.env.HMD_ALLOW_FREEURL === 'true') : !!config.allowfreeurl;
// db
-var db = config.db || {
- dialect: 'sqlite',
- storage: './db.hackmd.sqlite'
-};
+var dburl = config.dburl || process.env.HMD_DB_URL || process.env.DATABASE_URL;
+var db = config.db || {};
// ssl path
var sslkeypath = config.sslkeypath || '';
@@ -131,6 +129,7 @@ module.exports = {
usecdn: usecdn,
allowanonymous: allowanonymous,
allowfreeurl: allowfreeurl,
+ dburl: dburl,
db: db,
sslkeypath: path.join(cwd, sslkeypath),
sslcertpath: path.join(cwd, sslcertpath),
diff --git a/lib/models/index.js b/lib/models/index.js
index d52f5508..de6cd13c 100644
--- a/lib/models/index.js
+++ b/lib/models/index.js
@@ -13,10 +13,12 @@ var dbconfig = config.db;
dbconfig.logging = config.debug ? logger.info : false;
var sequelize = null;
-if (dbconfig.hasOwnProperty('username') || dbconfig.hasOwnProperty('password'))
- sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig);
+
+// Heroku specific
+if (config.dburl)
+ sequelize = new Sequelize(config.dburl, dbconfig);
else
- sequelize = new Sequelize(dbconfig.database, dbconfig);
+ sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig);
var db = {};