mirror of
https://github.com/stolksdorf/homebrewery.git
synced 2025-12-22 07:41:30 +00:00
moving the db setup out
This commit is contained in:
18
server/db.js
Normal file
18
server/db.js
Normal 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();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user