diff --git a/config.js b/config.js index b31a895..b6d9300 100644 --- a/config.js +++ b/config.js @@ -13,8 +13,7 @@ var config = { storageOpts: { mongoDb: { - host: 'localhost', - port: 27017, + uri: 'mongodb://localhost:27017/bws', }, }, lockOpts: { diff --git a/lib/storage.js b/lib/storage.js index c1f1a2c..c72a0c9 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -33,14 +33,13 @@ Storage.prototype.connect = function(opts, cb) { if (this.db) return cb(null); var config = opts.mongoDb || {}; - var url = 'mongodb://' + (config.host || 'localhost') + ':' + (config.port ||  27017) + '/bws'; - mongodb.MongoClient.connect(url, function(err, db) { + mongodb.MongoClient.connect(config.uri, function(err, db) { if (err) { - log.error('Unable to connect to the mongoDB server.'); + log.error('Unable to connect to the mongoDB server on ', config.uri); return cb(err); } self.db = db; - console.log('Connection established to ', url); + console.log('Connection established to ', config.uri); return cb(null); }); };