aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2015-11-07 14:16:26 +0100
committerChocobozzz <florian.bigard@gmail.com>2015-11-07 14:16:26 +0100
commit34ca3b5225479a5da986c86ee4c42a73ae6df5ad (patch)
tree561ba5ae1adccd5729305a8cc17d13d24a0c2ddb /routes/api
parentf5a60a5138135a3412dfbcfd6e564f7aa47a55c2 (diff)
downloadPeerTube-34ca3b5225479a5da986c86ee4c42a73ae6df5ad.tar.gz
PeerTube-34ca3b5225479a5da986c86ee4c42a73ae6df5ad.tar.zst
PeerTube-34ca3b5225479a5da986c86ee4c42a73ae6df5ad.zip
Add requests parameters validations
Diffstat (limited to 'routes/api')
-rw-r--r--routes/api/v1/pods.js3
-rw-r--r--routes/api/v1/remoteVideos.js5
-rw-r--r--routes/api/v1/videos.js9
3 files changed, 10 insertions, 7 deletions
diff --git a/routes/api/v1/pods.js b/routes/api/v1/pods.js
index 961388fcb..8ae676834 100644
--- a/routes/api/v1/pods.js
+++ b/routes/api/v1/pods.js
@@ -4,6 +4,7 @@
4 var express = require('express') 4 var express = require('express')
5 var router = express.Router() 5 var router = express.Router()
6 var middleware = require('../../../middlewares') 6 var middleware = require('../../../middlewares')
7 var reqValidator = require('../../../middlewares/reqValidators').pods
7 var pods = require('../../../src/pods') 8 var pods = require('../../../src/pods')
8 9
9 function listPods (req, res, next) { 10 function listPods (req, res, next) {
@@ -32,7 +33,7 @@
32 33
33 router.get('/', middleware.cache(false), listPods) 34 router.get('/', middleware.cache(false), listPods)
34 router.get('/makefriends', middleware.cache(false), makeFriends) 35 router.get('/makefriends', middleware.cache(false), makeFriends)
35 router.post('/', middleware.cache(false), addPods) 36 router.post('/', reqValidator.podsAdd, middleware.cache(false), addPods)
36 37
37 module.exports = router 38 module.exports = router
38})() 39})()
diff --git a/routes/api/v1/remoteVideos.js b/routes/api/v1/remoteVideos.js
index 88b8e879b..23bdcbe24 100644
--- a/routes/api/v1/remoteVideos.js
+++ b/routes/api/v1/remoteVideos.js
@@ -4,6 +4,7 @@
4 var express = require('express') 4 var express = require('express')
5 var router = express.Router() 5 var router = express.Router()
6 var middleware = require('../../../middlewares') 6 var middleware = require('../../../middlewares')
7 var requestValidator = require('../../../middlewares/reqValidators').remote
7 var videos = require('../../../src/videos') 8 var videos = require('../../../src/videos')
8 9
9 function addRemoteVideos (req, res, next) { 10 function addRemoteVideos (req, res, next) {
@@ -22,8 +23,8 @@
22 }) 23 })
23 } 24 }
24 25
25 router.post('/add', middleware.cache(false), middleware.decryptBody, addRemoteVideos) 26 router.post('/add', requestValidator.secureRequest, middleware.decryptBody, requestValidator.remoteVideosAdd, middleware.cache(false), addRemoteVideos)
26 router.post('/remove', middleware.cache(false), middleware.decryptBody, removeRemoteVideo) 27 router.post('/remove', requestValidator.secureRequest, middleware.decryptBody, requestValidator.remoteVideosRemove, middleware.cache(false), removeRemoteVideo)
27 28
28 module.exports = router 29 module.exports = router
29})() 30})()
diff --git a/routes/api/v1/videos.js b/routes/api/v1/videos.js
index 246620ac6..06b248244 100644
--- a/routes/api/v1/videos.js
+++ b/routes/api/v1/videos.js
@@ -4,6 +4,7 @@
4 var express = require('express') 4 var express = require('express')
5 var router = express.Router() 5 var router = express.Router()
6 var middleware = require('../../../middlewares') 6 var middleware = require('../../../middlewares')
7 var reqValidator = require('../../../middlewares/reqValidators').videos
7 var videos = require('../../../src/videos') 8 var videos = require('../../../src/videos')
8 9
9 function listVideos (req, res, next) { 10 function listVideos (req, res, next) {
@@ -52,10 +53,10 @@
52 } 53 }
53 54
54 router.get('/', middleware.cache(false), listVideos) 55 router.get('/', middleware.cache(false), listVideos)
55 router.post('/', middleware.cache(false), addVideos) 56 router.post('/', reqValidator.videosAdd, middleware.cache(false), addVideos)
56 router.get('/search/:name', middleware.cache(false), searchVideos) 57 router.get('/search/:name', reqValidator.videosSearch, middleware.cache(false), searchVideos)
57 router.get('/:id', middleware.cache(false), getVideos) 58 router.get('/:id', reqValidator.videosGet, middleware.cache(false), getVideos)
58 router.delete('/:id', middleware.cache(false), removeVideo) 59 router.delete('/:id', reqValidator.videosRemove, middleware.cache(false), removeVideo)
59 60
60 module.exports = router 61 module.exports = router
61})() 62})()