From 65fcc3119c334b75dd13bcfdebf186afdc580a8f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 May 2017 22:22:03 +0200 Subject: First typescript iteration --- server/middlewares/validators/remote/index.js | 13 -------- server/middlewares/validators/remote/index.ts | 2 ++ server/middlewares/validators/remote/signature.js | 21 ------------- server/middlewares/validators/remote/signature.ts | 17 +++++++++++ server/middlewares/validators/remote/videos.js | 37 ----------------------- server/middlewares/validators/remote/videos.ts | 34 +++++++++++++++++++++ 6 files changed, 53 insertions(+), 71 deletions(-) delete mode 100644 server/middlewares/validators/remote/index.js create mode 100644 server/middlewares/validators/remote/index.ts delete mode 100644 server/middlewares/validators/remote/signature.js create mode 100644 server/middlewares/validators/remote/signature.ts delete mode 100644 server/middlewares/validators/remote/videos.js create mode 100644 server/middlewares/validators/remote/videos.ts (limited to 'server/middlewares/validators/remote') 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 @@ -'use strict' - -const remoteSignatureValidators = require('./signature') -const remoteVideosValidators = require('./videos') - -const validators = { - signature: remoteSignatureValidators, - videos: remoteVideosValidators -} - -// --------------------------------------------------------------------------- - -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 @@ +export * from './signature' +export * from './videos' diff --git a/server/middlewares/validators/remote/signature.js b/server/middlewares/validators/remote/signature.js deleted file mode 100644 index 002232c05..000000000 --- a/server/middlewares/validators/remote/signature.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict' - -const checkErrors = require('../utils').checkErrors -const logger = require('../../../helpers/logger') - -const validatorsRemoteSignature = { - signature -} - -function signature (req, res, next) { - req.checkBody('signature.host', 'Should have a signature host').isURL() - req.checkBody('signature.signature', 'Should have a signature').notEmpty() - - logger.debug('Checking signature parameters', { parameters: { signature: req.body.signature } }) - - checkErrors(req, res, next) -} - -// --------------------------------------------------------------------------- - -module.exports = validatorsRemoteSignature diff --git a/server/middlewares/validators/remote/signature.ts b/server/middlewares/validators/remote/signature.ts new file mode 100644 index 000000000..6e3ebe7db --- /dev/null +++ b/server/middlewares/validators/remote/signature.ts @@ -0,0 +1,17 @@ +import { logger } from '../../../helpers' +import { checkErrors } from '../utils' + +function signatureValidator (req, res, next) { + req.checkBody('signature.host', 'Should have a signature host').isURL() + req.checkBody('signature.signature', 'Should have a signature').notEmpty() + + logger.debug('Checking signature parameters', { parameters: { signature: req.body.signature } }) + + checkErrors(req, res, next) +} + +// --------------------------------------------------------------------------- + +export { + signatureValidator +} diff --git a/server/middlewares/validators/remote/videos.js b/server/middlewares/validators/remote/videos.js deleted file mode 100644 index f2c6cba5e..000000000 --- a/server/middlewares/validators/remote/videos.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict' - -const checkErrors = require('../utils').checkErrors -const logger = require('../../../helpers/logger') - -const validatorsRemoteVideos = { - remoteVideos, - remoteQaduVideos, - remoteEventsVideos -} - -function remoteVideos (req, res, next) { - req.checkBody('data').isEachRemoteRequestVideosValid() - - logger.debug('Checking remoteVideos parameters', { parameters: req.body }) - - checkErrors(req, res, next) -} - -function remoteQaduVideos (req, res, next) { - req.checkBody('data').isEachRemoteRequestVideosQaduValid() - - logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body }) - - checkErrors(req, res, next) -} - -function remoteEventsVideos (req, res, next) { - req.checkBody('data').isEachRemoteRequestVideosEventsValid() - - logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body }) - - checkErrors(req, res, next) -} -// --------------------------------------------------------------------------- - -module.exports = validatorsRemoteVideos diff --git a/server/middlewares/validators/remote/videos.ts b/server/middlewares/validators/remote/videos.ts new file mode 100644 index 000000000..3380c29e2 --- /dev/null +++ b/server/middlewares/validators/remote/videos.ts @@ -0,0 +1,34 @@ +import { logger } from '../../../helpers' +import { checkErrors } from '../utils' + +function remoteVideosValidator (req, res, next) { + req.checkBody('data').isEachRemoteRequestVideosValid() + + logger.debug('Checking remoteVideos parameters', { parameters: req.body }) + + checkErrors(req, res, next) +} + +function remoteQaduVideosValidator (req, res, next) { + req.checkBody('data').isEachRemoteRequestVideosQaduValid() + + logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body }) + + checkErrors(req, res, next) +} + +function remoteEventsVideosValidator (req, res, next) { + req.checkBody('data').isEachRemoteRequestVideosEventsValid() + + logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body }) + + checkErrors(req, res, next) +} + +// --------------------------------------------------------------------------- + +export { + remoteVideosValidator, + remoteQaduVideosValidator, + remoteEventsVideosValidator +} -- cgit v1.2.3