moving the db setup out

This commit is contained in:
Scott Tolksdorf
2017-01-22 12:45:46 -05:00
parent 25e0a1607a
commit a0bc4fddf8
3 changed files with 25 additions and 8 deletions
+18
View File
@@ -0,0 +1,18 @@
module.exports = {
connect : ()=>{
return new Promise((resolve, reject)=>{
require('mongoose')
.connect(process.env.MONGODB_URI || process.env.MONGOLAB_URI || 'mongodb://localhost/homebrewery',
(err) => {
if(err){
console.log('Error : Could not connect to a Mongo Database.');
console.log(' If you are running locally, make sure mongodb.exe is running.');
return reject();
}
return resolve();
}
);
});
}
}