mirror of
https://github.com/stolksdorf/homebrewery.git
synced 2025-12-14 04:35:56 +00:00
moving the db setup out
This commit is contained in:
@@ -14,13 +14,7 @@ const config = require('nconf')
|
|||||||
.file('defaults', { file: 'config/default.json' });
|
.file('defaults', { file: 'config/default.json' });
|
||||||
|
|
||||||
//DB
|
//DB
|
||||||
require('mongoose')
|
require('./server/db.js').connect();
|
||||||
.connect(process.env.MONGODB_URI || process.env.MONGOLAB_URI || 'mongodb://localhost/naturalcrit')
|
|
||||||
.connection.on('error', () => {
|
|
||||||
console.error('Error : Could not connect to a Mongo Database.');
|
|
||||||
console.error(' If you are running locally, make sure mongodb.exe is running.');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
//Middleware
|
//Middleware
|
||||||
const mw = require('./server/middleware.js');
|
const mw = require('./server/middleware.js');
|
||||||
|
|||||||
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();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,11 +12,16 @@ describe('BrewDB', () => {
|
|||||||
return BrewDB.create({
|
return BrewDB.create({
|
||||||
text : "Brew Text"
|
text : "Brew Text"
|
||||||
}).then((brew) => {
|
}).then((brew) => {
|
||||||
|
console.log('running?');
|
||||||
should.exist(brew);
|
should.exist(brew);
|
||||||
brew.should.have.property('editId').that.is.a('string');
|
brew.should.have.property('editId').that.is.a('string');
|
||||||
brew.should.have.property('shareId').that.is.a('string');
|
brew.should.have.property('shareId').that.is.a('string');
|
||||||
brew.should.have.property('text').that.is.a('string');
|
brew.should.have.property('text').that.is.a('string');
|
||||||
});
|
done();
|
||||||
|
})
|
||||||
|
.catch(()=>{
|
||||||
|
console.log('yo');
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user