specs for donors model

This commit is contained in:
Arjun Patel
2019-01-12 14:03:34 -08:00
parent ec2a3b5362
commit 43bf237942
3 changed files with 56 additions and 36 deletions
+16 -4
View File
@@ -17,10 +17,7 @@ app.use((req, res, next) => {
);
if (req.method == 'OPTIONS') {
res.header(
'Access-Control-Allow-Methods',
'PUT, POST, GET, DELETE, PATCH'
);
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, PATCH');
return res.status(200).json({});
}
@@ -52,6 +49,21 @@ app.get('/', function(req, res, next) {
app.use('/api/donors', require('./app/routes/donors.route.js'));
app.use('/api/auth', require('./app/routes/auth.route.js'));
app.use((req, res, next) => {
const error = new Error('Not found');
error.status = 404;
next(error);
});
app.use((error, req, res, next) => {
res.status(error.status || 500);
res.json({
error: {
message: error.message
}
});
});
// Create a Server
var server = app.listen(port, function() {
var host = server.address().address;