diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/pods.ts | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts index 481a66957..d0981cd57 100644 --- a/server/middlewares/validators/pods.ts +++ b/server/middlewares/validators/pods.ts | |||
@@ -58,9 +58,33 @@ function podsAddValidator (req: express.Request, res: express.Response, next: ex | |||
58 | }) | 58 | }) |
59 | } | 59 | } |
60 | 60 | ||
61 | function podRemoveValidator (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
62 | req.checkParams('id', 'Should have a valid id').notEmpty().isNumeric() | ||
63 | |||
64 | logger.debug('Checking podRemoveValidator parameters', { parameters: req.params }) | ||
65 | |||
66 | checkErrors(req, res, function () { | ||
67 | db.Pod.load(req.params.id) | ||
68 | .then(pod => { | ||
69 | if (!pod) { | ||
70 | logger.error('Cannot find pod %d.', req.params.id) | ||
71 | return res.sendStatus(404) | ||
72 | } | ||
73 | |||
74 | res.locals.pod = pod | ||
75 | return next() | ||
76 | }) | ||
77 | .catch(err => { | ||
78 | logger.error('Cannot load pod %d.', req.params.id, err) | ||
79 | res.sendStatus(500) | ||
80 | }) | ||
81 | }) | ||
82 | } | ||
83 | |||
61 | // --------------------------------------------------------------------------- | 84 | // --------------------------------------------------------------------------- |
62 | 85 | ||
63 | export { | 86 | export { |
64 | makeFriendsValidator, | 87 | makeFriendsValidator, |
65 | podsAddValidator | 88 | podsAddValidator, |
89 | podRemoveValidator | ||
66 | } | 90 | } |