From 34ca3b5225479a5da986c86ee4c42a73ae6df5ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 7 Nov 2015 14:16:26 +0100 Subject: Add requests parameters validations --- routes/api/v1/pods.js | 3 ++- routes/api/v1/remoteVideos.js | 5 +++-- routes/api/v1/videos.js | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'routes/api/v1') 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 @@ var express = require('express') var router = express.Router() var middleware = require('../../../middlewares') + var reqValidator = require('../../../middlewares/reqValidators').pods var pods = require('../../../src/pods') function listPods (req, res, next) { @@ -32,7 +33,7 @@ router.get('/', middleware.cache(false), listPods) router.get('/makefriends', middleware.cache(false), makeFriends) - router.post('/', middleware.cache(false), addPods) + router.post('/', reqValidator.podsAdd, middleware.cache(false), addPods) module.exports = router })() 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 @@ var express = require('express') var router = express.Router() var middleware = require('../../../middlewares') + var requestValidator = require('../../../middlewares/reqValidators').remote var videos = require('../../../src/videos') function addRemoteVideos (req, res, next) { @@ -22,8 +23,8 @@ }) } - router.post('/add', middleware.cache(false), middleware.decryptBody, addRemoteVideos) - router.post('/remove', middleware.cache(false), middleware.decryptBody, removeRemoteVideo) + router.post('/add', requestValidator.secureRequest, middleware.decryptBody, requestValidator.remoteVideosAdd, middleware.cache(false), addRemoteVideos) + router.post('/remove', requestValidator.secureRequest, middleware.decryptBody, requestValidator.remoteVideosRemove, middleware.cache(false), removeRemoteVideo) module.exports = router })() 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 @@ var express = require('express') var router = express.Router() var middleware = require('../../../middlewares') + var reqValidator = require('../../../middlewares/reqValidators').videos var videos = require('../../../src/videos') function listVideos (req, res, next) { @@ -52,10 +53,10 @@ } router.get('/', middleware.cache(false), listVideos) - router.post('/', middleware.cache(false), addVideos) - router.get('/search/:name', middleware.cache(false), searchVideos) - router.get('/:id', middleware.cache(false), getVideos) - router.delete('/:id', middleware.cache(false), removeVideo) + router.post('/', reqValidator.videosAdd, middleware.cache(false), addVideos) + router.get('/search/:name', reqValidator.videosSearch, middleware.cache(false), searchVideos) + router.get('/:id', reqValidator.videosGet, middleware.cache(false), getVideos) + router.delete('/:id', reqValidator.videosRemove, middleware.cache(false), removeVideo) module.exports = router })() -- cgit v1.2.3