diff options
author | Max Wu | 2016-12-22 22:29:52 +0800 |
---|---|---|
committer | GitHub | 2016-12-22 22:29:52 +0800 |
commit | 8cf849e825e96510c064479bbf89b595e6728511 (patch) | |
tree | e661253d4393ecc61772548fda7f457e92f689ac /lib | |
parent | 8153fa32ed963f3c8b122dd673bb3ab64323e2ab (diff) | |
parent | c58f28a9d43804018c94fd2899b50863f1b5a2b6 (diff) |
Merge pull request #294 from bananaappletw/master
Fix #293
Diffstat (limited to 'lib')
-rw-r--r-- | lib/config.js | 7 | ||||
-rw-r--r-- | lib/models/index.js | 8 |
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 = {}; |