Return next to send a 500 status code
This commit is contained in:
parent
dd0f21d1ea
commit
e63dc45fa3
3 changed files with 10 additions and 10 deletions
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
function listPods (req, res, next) {
|
function listPods (req, res, next) {
|
||||||
pods.list(function (err, pods_list) {
|
pods.list(function (err, pods_list) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
res.json(pods_list)
|
res.json(pods_list)
|
||||||
})
|
})
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
function addPods (req, res, next) {
|
function addPods (req, res, next) {
|
||||||
pods.add(req.body.data, function (err, json) {
|
pods.add(req.body.data, function (err, json) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
res.json(json)
|
res.json(json)
|
||||||
})
|
})
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
function makeFriends (req, res, next) {
|
function makeFriends (req, res, next) {
|
||||||
pods.makeFriends(function (err) {
|
pods.makeFriends(function (err) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
function addRemoteVideos (req, res, next) {
|
function addRemoteVideos (req, res, next) {
|
||||||
videos.addRemote(req.body.data, function (err, video) {
|
videos.addRemote(req.body.data, function (err, video) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
res.json(video)
|
res.json(video)
|
||||||
})
|
})
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
function removeRemoteVideo (req, res, next) {
|
function removeRemoteVideo (req, res, next) {
|
||||||
videos.removeRemote(req.body.signature.url, req.body.data.magnetUri, function (err) {
|
videos.removeRemote(req.body.signature.url, req.body.data.magnetUri, function (err) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
res.status(204)
|
res.status(204)
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
function listVideos (req, res, next) {
|
function listVideos (req, res, next) {
|
||||||
videos.list(function (err, videos_list) {
|
videos.list(function (err, videos_list) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
res.json(videos_list)
|
res.json(videos_list)
|
||||||
})
|
})
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
function searchVideos (req, res, next) {
|
function searchVideos (req, res, next) {
|
||||||
videos.search(req.params.name, function (err, videos_list) {
|
videos.search(req.params.name, function (err, videos_list) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
res.json(videos_list)
|
res.json(videos_list)
|
||||||
})
|
})
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
function addVideos (req, res, next) {
|
function addVideos (req, res, next) {
|
||||||
videos.add({ video: req.files.input_video, data: req.body }, function (err) {
|
videos.add({ video: req.files.input_video, data: req.body }, function (err) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
// TODO : include Location of the new video
|
// TODO : include Location of the new video
|
||||||
res.sendStatus(201)
|
res.sendStatus(201)
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
function getVideos (req, res, next) {
|
function getVideos (req, res, next) {
|
||||||
videos.get(req.params.id, function (err, video) {
|
videos.get(req.params.id, function (err, video) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
if (video === null) {
|
if (video === null) {
|
||||||
return res.sendStatus(404)
|
return res.sendStatus(404)
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
function removeVideo (req, res, next) {
|
function removeVideo (req, res, next) {
|
||||||
videos.remove(req.params.id, function (err) {
|
videos.remove(req.params.id, function (err) {
|
||||||
if (err) next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue