specs for donors model
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user