mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-13 06:32:39 +00:00
Split off app into own file
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const log = require('loglevel');
|
||||
const mongoose = require('mongoose');
|
||||
mongoose.Promise = Promise;
|
||||
|
||||
@@ -7,17 +8,17 @@ module.exports = {
|
||||
connect : ()=>{
|
||||
return new Promise((resolve, reject)=>{
|
||||
if(mongoose.connection.readyState == 1){
|
||||
console.log('already connected');
|
||||
log.info('DB already connected');
|
||||
return resolve();
|
||||
}
|
||||
mongoose.connect(dbPath,
|
||||
(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.');
|
||||
log.info('Error : Could not connect to a Mongo Database.');
|
||||
log.info(' If you are running locally, make sure mongodb.exe is running.');
|
||||
return reject(err);
|
||||
}
|
||||
console.log('mongo connected.');
|
||||
log.info('DB connected.');
|
||||
return resolve();
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user