aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/api/v1/pods.js
diff options
context:
space:
mode:
Diffstat (limited to 'routes/api/v1/pods.js')
-rw-r--r--routes/api/v1/pods.js69
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})()