aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/pods.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-19 09:43:01 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-19 09:43:01 +0200
commit8a02bd0433b7101c5ea36e87a4edb63204d2adec (patch)
treed7ab4b6164aef752c216bd2f22f8b3b270a724b8 /server/middlewares/validators/pods.ts
parent9fd540562c356cb54b98861d2d9e7d4fbfcd00e0 (diff)
downloadPeerTube-8a02bd0433b7101c5ea36e87a4edb63204d2adec.tar.gz
PeerTube-8a02bd0433b7101c5ea36e87a4edb63204d2adec.tar.zst
PeerTube-8a02bd0433b7101c5ea36e87a4edb63204d2adec.zip
Add pod list endpoint with pagination, sort...
Diffstat (limited to 'server/middlewares/validators/pods.ts')
-rw-r--r--server/middlewares/validators/pods.ts29
1 files changed, 1 insertions, 28 deletions
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts
index ab7702e78..575c36526 100644
--- a/server/middlewares/validators/pods.ts
+++ b/server/middlewares/validators/pods.ts
@@ -3,7 +3,7 @@ import * as express from 'express'
3 3
4import { database as db } from '../../initializers/database' 4import { database as db } from '../../initializers/database'
5import { checkErrors } from './utils' 5import { checkErrors } from './utils'
6import { logger, isEachUniqueHostValid, isHostValid } from '../../helpers' 6import { logger, isEachUniqueHostValid } from '../../helpers'
7import { CONFIG } from '../../initializers' 7import { CONFIG } from '../../initializers'
8import { hasFriends } from '../../lib' 8import { hasFriends } from '../../lib'
9import { isTestInstance } from '../../helpers' 9import { isTestInstance } from '../../helpers'
@@ -41,32 +41,6 @@ const makeFriendsValidator = [
41 } 41 }
42] 42]
43 43
44const podsAddValidator = [
45 body('host').custom(isHostValid).withMessage('Should have a host'),
46 body('email').isEmail().withMessage('Should have an email'),
47 body('publicKey').not().isEmpty().withMessage('Should have a public key'),
48
49 (req: express.Request, res: express.Response, next: express.NextFunction) => {
50 logger.debug('Checking podsAdd parameters', { parameters: req.body })
51
52 checkErrors(req, res, () => {
53 db.Pod.loadByHost(req.body.host)
54 .then(pod => {
55 // Pod with this host already exists
56 if (pod) {
57 return res.sendStatus(409)
58 }
59
60 return next()
61 })
62 .catch(err => {
63 logger.error('Cannot load pod by host.', err)
64 res.sendStatus(500)
65 })
66 })
67 }
68]
69
70const podRemoveValidator = [ 44const podRemoveValidator = [
71 param('id').isNumeric().not().isEmpty().withMessage('Should have a valid id'), 45 param('id').isNumeric().not().isEmpty().withMessage('Should have a valid id'),
72 46
@@ -96,6 +70,5 @@ const podRemoveValidator = [
96 70
97export { 71export {
98 makeFriendsValidator, 72 makeFriendsValidator,
99 podsAddValidator,
100 podRemoveValidator 73 podRemoveValidator
101} 74}