diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 09:43:01 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 09:43:01 +0200 |
commit | 8a02bd0433b7101c5ea36e87a4edb63204d2adec (patch) | |
tree | d7ab4b6164aef752c216bd2f22f8b3b270a724b8 /server/middlewares/validators/pods.ts | |
parent | 9fd540562c356cb54b98861d2d9e7d4fbfcd00e0 (diff) | |
download | PeerTube-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.ts | 29 |
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 | ||
4 | import { database as db } from '../../initializers/database' | 4 | import { database as db } from '../../initializers/database' |
5 | import { checkErrors } from './utils' | 5 | import { checkErrors } from './utils' |
6 | import { logger, isEachUniqueHostValid, isHostValid } from '../../helpers' | 6 | import { logger, isEachUniqueHostValid } from '../../helpers' |
7 | import { CONFIG } from '../../initializers' | 7 | import { CONFIG } from '../../initializers' |
8 | import { hasFriends } from '../../lib' | 8 | import { hasFriends } from '../../lib' |
9 | import { isTestInstance } from '../../helpers' | 9 | import { isTestInstance } from '../../helpers' |
@@ -41,32 +41,6 @@ const makeFriendsValidator = [ | |||
41 | } | 41 | } |
42 | ] | 42 | ] |
43 | 43 | ||
44 | const 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 | |||
70 | const podRemoveValidator = [ | 44 | const 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 | ||
97 | export { | 71 | export { |
98 | makeFriendsValidator, | 72 | makeFriendsValidator, |
99 | podsAddValidator, | ||
100 | podRemoveValidator | 73 | podRemoveValidator |
101 | } | 74 | } |