aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/remote
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-15 22:22:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-20 09:57:40 +0200
commit65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch)
tree4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/middlewares/validators/remote
parentd5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff)
downloadPeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip
First typescript iteration
Diffstat (limited to 'server/middlewares/validators/remote')
-rw-r--r--server/middlewares/validators/remote/index.js13
-rw-r--r--server/middlewares/validators/remote/index.ts2
-rw-r--r--server/middlewares/validators/remote/signature.ts (renamed from server/middlewares/validators/remote/signature.js)16
-rw-r--r--server/middlewares/validators/remote/videos.ts (renamed from server/middlewares/validators/remote/videos.js)25
4 files changed, 19 insertions, 37 deletions
diff --git a/server/middlewares/validators/remote/index.js b/server/middlewares/validators/remote/index.js
deleted file mode 100644
index 022a2fe50..000000000
--- a/server/middlewares/validators/remote/index.js
+++ /dev/null
@@ -1,13 +0,0 @@
1'use strict'
2
3const remoteSignatureValidators = require('./signature')
4const remoteVideosValidators = require('./videos')
5
6const validators = {
7 signature: remoteSignatureValidators,
8 videos: remoteVideosValidators
9}
10
11// ---------------------------------------------------------------------------
12
13module.exports = validators
diff --git a/server/middlewares/validators/remote/index.ts b/server/middlewares/validators/remote/index.ts
new file mode 100644
index 000000000..d0d7740b1
--- /dev/null
+++ b/server/middlewares/validators/remote/index.ts
@@ -0,0 +1,2 @@
1export * from './signature'
2export * from './videos'
diff --git a/server/middlewares/validators/remote/signature.js b/server/middlewares/validators/remote/signature.ts
index 002232c05..6e3ebe7db 100644
--- a/server/middlewares/validators/remote/signature.js
+++ b/server/middlewares/validators/remote/signature.ts
@@ -1,13 +1,7 @@
1'use strict' 1import { logger } from '../../../helpers'
2import { checkErrors } from '../utils'
2 3
3const checkErrors = require('../utils').checkErrors 4function signatureValidator (req, res, next) {
4const logger = require('../../../helpers/logger')
5
6const validatorsRemoteSignature = {
7 signature
8}
9
10function signature (req, res, next) {
11 req.checkBody('signature.host', 'Should have a signature host').isURL() 5 req.checkBody('signature.host', 'Should have a signature host').isURL()
12 req.checkBody('signature.signature', 'Should have a signature').notEmpty() 6 req.checkBody('signature.signature', 'Should have a signature').notEmpty()
13 7
@@ -18,4 +12,6 @@ function signature (req, res, next) {
18 12
19// --------------------------------------------------------------------------- 13// ---------------------------------------------------------------------------
20 14
21module.exports = validatorsRemoteSignature 15export {
16 signatureValidator
17}
diff --git a/server/middlewares/validators/remote/videos.js b/server/middlewares/validators/remote/videos.ts
index f2c6cba5e..3380c29e2 100644
--- a/server/middlewares/validators/remote/videos.js
+++ b/server/middlewares/validators/remote/videos.ts
@@ -1,15 +1,7 @@
1'use strict' 1import { logger } from '../../../helpers'
2import { checkErrors } from '../utils'
2 3
3const checkErrors = require('../utils').checkErrors 4function remoteVideosValidator (req, res, next) {
4const logger = require('../../../helpers/logger')
5
6const validatorsRemoteVideos = {
7 remoteVideos,
8 remoteQaduVideos,
9 remoteEventsVideos
10}
11
12function remoteVideos (req, res, next) {
13 req.checkBody('data').isEachRemoteRequestVideosValid() 5 req.checkBody('data').isEachRemoteRequestVideosValid()
14 6
15 logger.debug('Checking remoteVideos parameters', { parameters: req.body }) 7 logger.debug('Checking remoteVideos parameters', { parameters: req.body })
@@ -17,7 +9,7 @@ function remoteVideos (req, res, next) {
17 checkErrors(req, res, next) 9 checkErrors(req, res, next)
18} 10}
19 11
20function remoteQaduVideos (req, res, next) { 12function remoteQaduVideosValidator (req, res, next) {
21 req.checkBody('data').isEachRemoteRequestVideosQaduValid() 13 req.checkBody('data').isEachRemoteRequestVideosQaduValid()
22 14
23 logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body }) 15 logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body })
@@ -25,13 +17,18 @@ function remoteQaduVideos (req, res, next) {
25 checkErrors(req, res, next) 17 checkErrors(req, res, next)
26} 18}
27 19
28function remoteEventsVideos (req, res, next) { 20function remoteEventsVideosValidator (req, res, next) {
29 req.checkBody('data').isEachRemoteRequestVideosEventsValid() 21 req.checkBody('data').isEachRemoteRequestVideosEventsValid()
30 22
31 logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body }) 23 logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body })
32 24
33 checkErrors(req, res, next) 25 checkErrors(req, res, next)
34} 26}
27
35// --------------------------------------------------------------------------- 28// ---------------------------------------------------------------------------
36 29
37module.exports = validatorsRemoteVideos 30export {
31 remoteVideosValidator,
32 remoteQaduVideosValidator,
33 remoteEventsVideosValidator
34}