diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-01-30 17:05:22 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-01-30 17:05:22 +0100 |
commit | cda021079ff455cc0fd0eb95a5395fa808ab63d1 (patch) | |
tree | 056716de7460462b74b861051a5e9da6e2633fce /routes/api/v1/pods.js | |
parent | 86435b9baedfe300a28ea4545511c1b50d4119f6 (diff) | |
download | PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.gz PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.zst PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.zip |
New directory organization
Diffstat (limited to 'routes/api/v1/pods.js')
-rw-r--r-- | routes/api/v1/pods.js | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/routes/api/v1/pods.js b/routes/api/v1/pods.js deleted file mode 100644 index 2430b0d7e..000000000 --- a/routes/api/v1/pods.js +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | ;(function () { | ||
2 | 'use strict' | ||
3 | |||
4 | var express = require('express') | ||
5 | var router = express.Router() | ||
6 | var middleware = require('../../../middlewares') | ||
7 | var miscMiddleware = middleware.misc | ||
8 | var reqValidator = middleware.reqValidators.pods | ||
9 | var secureRequest = middleware.reqValidators.remote.secureRequest | ||
10 | var pods = require('../../../src/pods') | ||
11 | |||
12 | function listPods (req, res, next) { | ||
13 | pods.list(function (err, pods_list) { | ||
14 | if (err) return next(err) | ||
15 | |||
16 | res.json(pods_list) | ||
17 | }) | ||
18 | } | ||
19 | |||
20 | function addPods (req, res, next) { | ||
21 | pods.add(req.body.data, function (err, json) { | ||
22 | if (err) return next(err) | ||
23 | |||
24 | res.json(json) | ||
25 | }) | ||
26 | } | ||
27 | |||
28 | function removePods (req, res, next) { | ||
29 | pods.remove(req.body.signature.url, function (err) { | ||
30 | if (err) return next(err) | ||
31 | |||
32 | res.sendStatus(204) | ||
33 | }) | ||
34 | } | ||
35 | |||
36 | function makeFriends (req, res, next) { | ||
37 | pods.hasFriends(function (err, has_friends) { | ||
38 | if (err) return next(err) | ||
39 | |||
40 | if (has_friends === true) { | ||
41 | // We need to quit our friends before make new ones | ||
42 | res.sendStatus(409) | ||
43 | } else { | ||
44 | pods.makeFriends(function (err) { | ||
45 | if (err) return next(err) | ||
46 | |||
47 | res.sendStatus(204) | ||
48 | }) | ||
49 | } | ||
50 | }) | ||
51 | } | ||
52 | |||
53 | function quitFriends (req, res, next) { | ||
54 | pods.quitFriends(function (err) { | ||
55 | if (err) return next(err) | ||
56 | |||
57 | res.sendStatus(204) | ||
58 | }) | ||
59 | } | ||
60 | |||
61 | router.get('/', miscMiddleware.cache(false), listPods) | ||
62 | router.get('/makefriends', miscMiddleware.cache(false), makeFriends) | ||
63 | router.get('/quitfriends', miscMiddleware.cache(false), quitFriends) | ||
64 | router.post('/', reqValidator.podsAdd, miscMiddleware.cache(false), addPods) | ||
65 | // Post because this is a secured request | ||
66 | router.post('/remove', secureRequest, miscMiddleware.decryptBody, removePods) | ||
67 | |||
68 | module.exports = router | ||
69 | })() | ||