diff --git a/routes/api/applications.js b/routes/api/applications.js index e436b80..409f43e 100644 --- a/routes/api/applications.js +++ b/routes/api/applications.js @@ -20,6 +20,9 @@ router.param('application', function (req, res, next, slug) { }).catch(next); }); +/** + * return all applications + */ router.get('/', auth.required, function (req, res, next) { let query = {}; let limit = 25; @@ -68,6 +71,9 @@ router.get('/', auth.required, function (req, res, next) { }).catch(next); }); +/** + * save an application + */ router.post('/', auth.required, function (req, res, next) { Promise.all([ User.findById(req.payload.id), @@ -106,7 +112,9 @@ router.post('/', auth.required, function (req, res, next) { }).catch(next); }); -// return an application +/** + * return an application + */ router.get('/:application', auth.required, function (req, res, next) { Promise.all([ req.payload ? User.findById(req.payload.id) : null, @@ -117,6 +125,9 @@ router.get('/:application', auth.required, function (req, res, next) { }).catch(next); }); +/** + * update an application + */ router.put('/:application', auth.required, function (req, res, next) { User.findById(req.payload.id).then(function (user) { if (req.application.author._id.toString() === req.payload.id.toString()) { @@ -141,7 +152,9 @@ router.put('/:application', auth.required, function (req, res, next) { }); }); -// delete application +/** + * delete an application + */ router.delete('/:application', auth.required, function (req, res, next) { User.findById(req.payload.id).then(function (user) { if (!user) { @@ -149,7 +162,7 @@ router.delete('/:application', auth.required, function (req, res, next) { } if (user.role == 'Admin' || req.application.author._id.toString() === req.payload.id.toString()) { return req.application.remove().then(function () { - return res.sendStatus(204); + return res.json({ deleted: true }); }); } else { return res.status(403).json({ errors: { "Forbidden": "Vous ne disposez pas des autorisations suffisantes" } }); diff --git a/routes/api/jumps.js b/routes/api/jumps.js index ec88766..ee58e88 100644 --- a/routes/api/jumps.js +++ b/routes/api/jumps.js @@ -610,7 +610,7 @@ router.delete('/:jump', auth.required, function (req, res, next) { } if (req.jump.author._id.toString() === req.payload.id.toString()) { return req.jump.remove().then(function () { - return res.sendStatus(204); + return res.json({ deleted: true }); }); } else { return res.status(403).json({ errors: { "Forbidden": "Vous ne disposez pas des autorisations suffisantes" } });