PeerTube/server/middlewares/validators/remote/videos.ts

49 lines
1.3 KiB
TypeScript
Raw Normal View History

2017-09-15 05:17:08 -05:00
import { body } from 'express-validator/check'
2017-06-10 15:15:25 -05:00
import * as express from 'express'
2017-09-15 05:17:08 -05:00
import {
logger,
isEachRemoteRequestVideosValid,
isEachRemoteRequestVideosQaduValid,
isEachRemoteRequestVideosEventsValid
} from '../../../helpers'
2017-05-15 15:22:03 -05:00
import { checkErrors } from '../utils'
2017-01-04 13:59:23 -06:00
2017-09-15 05:17:08 -05:00
const remoteVideosValidator = [
body('data').custom(isEachRemoteRequestVideosValid),
2017-01-04 13:59:23 -06:00
2017-09-15 05:17:08 -05:00
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking remoteVideos parameters', { parameters: req.body })
2017-01-04 13:59:23 -06:00
2017-09-15 05:17:08 -05:00
checkErrors(req, res, next)
}
]
2017-01-04 13:59:23 -06:00
2017-09-15 05:17:08 -05:00
const remoteQaduVideosValidator = [
body('data').custom(isEachRemoteRequestVideosQaduValid),
2017-09-15 05:17:08 -05:00
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body })
2017-09-15 05:17:08 -05:00
checkErrors(req, res, next)
}
]
2017-09-15 05:17:08 -05:00
const remoteEventsVideosValidator = [
body('data').custom(isEachRemoteRequestVideosEventsValid),
2017-02-26 11:57:33 -06:00
2017-09-15 05:17:08 -05:00
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body })
2017-02-26 11:57:33 -06:00
2017-09-15 05:17:08 -05:00
checkErrors(req, res, next)
}
]
2017-05-15 15:22:03 -05:00
2017-01-04 13:59:23 -06:00
// ---------------------------------------------------------------------------
2017-05-15 15:22:03 -05:00
export {
remoteVideosValidator,
remoteQaduVideosValidator,
remoteEventsVideosValidator
}