diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-05-15 22:22:03 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-05-20 09:57:40 +0200 |
commit | 65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch) | |
tree | 4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/middlewares/validators/remote | |
parent | d5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff) | |
download | PeerTube-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.js | 13 | ||||
-rw-r--r-- | server/middlewares/validators/remote/index.ts | 2 | ||||
-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 | |||
3 | const remoteSignatureValidators = require('./signature') | ||
4 | const remoteVideosValidators = require('./videos') | ||
5 | |||
6 | const validators = { | ||
7 | signature: remoteSignatureValidators, | ||
8 | videos: remoteVideosValidators | ||
9 | } | ||
10 | |||
11 | // --------------------------------------------------------------------------- | ||
12 | |||
13 | module.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 @@ | |||
1 | export * from './signature' | ||
2 | export * 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' | 1 | import { logger } from '../../../helpers' |
2 | import { checkErrors } from '../utils' | ||
2 | 3 | ||
3 | const checkErrors = require('../utils').checkErrors | 4 | function signatureValidator (req, res, next) { |
4 | const logger = require('../../../helpers/logger') | ||
5 | |||
6 | const validatorsRemoteSignature = { | ||
7 | signature | ||
8 | } | ||
9 | |||
10 | function 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 | ||
21 | module.exports = validatorsRemoteSignature | 15 | export { |
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' | 1 | import { logger } from '../../../helpers' |
2 | import { checkErrors } from '../utils' | ||
2 | 3 | ||
3 | const checkErrors = require('../utils').checkErrors | 4 | function remoteVideosValidator (req, res, next) { |
4 | const logger = require('../../../helpers/logger') | ||
5 | |||
6 | const validatorsRemoteVideos = { | ||
7 | remoteVideos, | ||
8 | remoteQaduVideos, | ||
9 | remoteEventsVideos | ||
10 | } | ||
11 | |||
12 | function 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 | ||
20 | function remoteQaduVideos (req, res, next) { | 12 | function 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 | ||
28 | function remoteEventsVideos (req, res, next) { | 20 | function 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 | ||
37 | module.exports = validatorsRemoteVideos | 30 | export { |
31 | remoteVideosValidator, | ||
32 | remoteQaduVideosValidator, | ||
33 | remoteEventsVideosValidator | ||
34 | } | ||