aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/pods.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-10 17:27:49 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:51 +0100
commit571389d43b8fc8aaf27e77c06f19b320b08dbbc9 (patch)
treee57173bcd0590d939c28952a29258fd02a281e35 /server/controllers/api/pods.ts
parent38fa2065831b5f55be0d7f30f19a62c967397208 (diff)
downloadPeerTube-571389d43b8fc8aaf27e77c06f19b320b08dbbc9.tar.gz
PeerTube-571389d43b8fc8aaf27e77c06f19b320b08dbbc9.tar.zst
PeerTube-571389d43b8fc8aaf27e77c06f19b320b08dbbc9.zip
Make it compile at least
Diffstat (limited to 'server/controllers/api/pods.ts')
-rw-r--r--server/controllers/api/pods.ts66
1 files changed, 2 insertions, 64 deletions
diff --git a/server/controllers/api/pods.ts b/server/controllers/api/pods.ts
index b44cd6b83..43df3f66f 100644
--- a/server/controllers/api/pods.ts
+++ b/server/controllers/api/pods.ts
@@ -1,26 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2 2import { getFormattedObjects } from '../../helpers'
3import { database as db } from '../../initializers/database' 3import { database as db } from '../../initializers/database'
4import { logger, getFormattedObjects } from '../../helpers' 4import { asyncMiddleware, paginationValidator, podsSortValidator, setPagination, setPodsSort } from '../../middlewares'
5import {
6 makeFriends,
7 quitFriends,
8 removeFriend
9} from '../../lib'
10import {
11 authenticate,
12 ensureUserHasRight,
13 makeFriendsValidator,
14 setBodyHostsPort,
15 podRemoveValidator,
16 paginationValidator,
17 setPagination,
18 setPodsSort,
19 podsSortValidator,
20 asyncMiddleware
21} from '../../middlewares'
22import { PodInstance } from '../../models'
23import { UserRight } from '../../../shared'
24 5
25const podsRouter = express.Router() 6const podsRouter = express.Router()
26 7
@@ -31,24 +12,6 @@ podsRouter.get('/',
31 setPagination, 12 setPagination,
32 asyncMiddleware(listPods) 13 asyncMiddleware(listPods)
33) 14)
34podsRouter.post('/make-friends',
35 authenticate,
36 ensureUserHasRight(UserRight.MANAGE_PODS),
37 makeFriendsValidator,
38 setBodyHostsPort,
39 asyncMiddleware(makeFriendsController)
40)
41podsRouter.get('/quit-friends',
42 authenticate,
43 ensureUserHasRight(UserRight.MANAGE_PODS),
44 asyncMiddleware(quitFriendsController)
45)
46podsRouter.delete('/:id',
47 authenticate,
48 ensureUserHasRight(UserRight.MANAGE_PODS),
49 podRemoveValidator,
50 asyncMiddleware(removeFriendController)
51)
52 15
53// --------------------------------------------------------------------------- 16// ---------------------------------------------------------------------------
54 17
@@ -63,28 +26,3 @@ async function listPods (req: express.Request, res: express.Response, next: expr
63 26
64 return res.json(getFormattedObjects(resultList.data, resultList.total)) 27 return res.json(getFormattedObjects(resultList.data, resultList.total))
65} 28}
66
67async function makeFriendsController (req: express.Request, res: express.Response, next: express.NextFunction) {
68 const hosts = req.body.hosts as string[]
69
70 // Don't wait the process that could be long
71 makeFriends(hosts)
72 .then(() => logger.info('Made friends!'))
73 .catch(err => logger.error('Could not make friends.', err))
74
75 return res.type('json').status(204).end()
76}
77
78async function quitFriendsController (req: express.Request, res: express.Response, next: express.NextFunction) {
79 await quitFriends()
80
81 return res.type('json').status(204).end()
82}
83
84async function removeFriendController (req: express.Request, res: express.Response, next: express.NextFunction) {
85 const pod = res.locals.pod as PodInstance
86
87 await removeFriend(pod)
88
89 return res.type('json').status(204).end()
90}