0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 06:32:39 +00:00

adding in some api tests

This commit is contained in:
Scott Tolksdorf
2017-01-01 17:47:26 -08:00
parent 5ba3f98696
commit 10f4759471
6 changed files with 68 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ router.get('/api/brew', (req, res, next) => {
//TODO
});
//Get

View File

@@ -78,6 +78,7 @@ const BrewData = {
return Brew.findOne(query).exec();
},
create : (brew) => {
console.log('here');
delete brew.shareId;
delete brew.editId;

26
server/error.js Normal file
View File

@@ -0,0 +1,26 @@
const ApiError = require('egads').extend('Server Error', 500, 'Generic Server Error');
ApiError.noBrew = ApiError.extend('Can not find a brew with that id', 404);
ApiError.expressHandler = (err, req, res, next) => {
if(err instanceof ApiError){
return res.status(err.status).send({
type : err.name,
message : err.message
});
}
//If server error, print the whole stack for debugging
return res.status(500).send({
message : err.message,
stack : err.stack
});
};
module.exports = ApiError;

View File

@@ -1,14 +0,0 @@
const egads = require('egads');
const Error = egads.extend('Server Error', 500, 'Generic Server Error');
Error.noBrew = Error.extend('Can not find a brew with that id', 404);
module.exports = Error;