0
0
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:
Scott Tolksdorf
2017-01-06 01:30:15 -05:00
parent 66ca09b36d
commit 174c2973f7
8 changed files with 71 additions and 76 deletions

View File

@@ -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();
}
);