aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/user-history.ts24
1 files changed, 19 insertions, 5 deletions
diff --git a/server/middlewares/validators/user-history.ts b/server/middlewares/validators/user-history.ts
index f9be26627..541910be5 100644
--- a/server/middlewares/validators/user-history.ts
+++ b/server/middlewares/validators/user-history.ts
@@ -1,6 +1,6 @@
1import express from 'express' 1import express from 'express'
2import { body, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { exists, isDateValid } from '../../helpers/custom-validators/misc' 3import { exists, isDateValid, isIdValid } from '../../helpers/custom-validators/misc'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './shared' 5import { areValidationErrors } from './shared'
6 6
@@ -18,13 +18,26 @@ const userHistoryListValidator = [
18 } 18 }
19] 19]
20 20
21const userHistoryRemoveValidator = [ 21const userHistoryRemoveAllValidator = [
22 body('beforeDate') 22 body('beforeDate')
23 .optional() 23 .optional()
24 .custom(isDateValid).withMessage('Should have a before date that conforms to ISO 8601'), 24 .custom(isDateValid).withMessage('Should have a before date that conforms to ISO 8601'),
25 25
26 (req: express.Request, res: express.Response, next: express.NextFunction) => { 26 (req: express.Request, res: express.Response, next: express.NextFunction) => {
27 logger.debug('Checking userHistoryRemoveValidator parameters', { parameters: req.body }) 27 logger.debug('Checking userHistoryRemoveAllValidator parameters', { parameters: req.body })
28
29 if (areValidationErrors(req, res)) return
30
31 return next()
32 }
33]
34
35const userHistoryRemoveElementValidator = [
36 param('videoId')
37 .custom(isIdValid).withMessage('Should have a valid video id'),
38
39 (req: express.Request, res: express.Response, next: express.NextFunction) => {
40 logger.debug('Checking userHistoryRemoveElementValidator parameters', { parameters: req.params })
28 41
29 if (areValidationErrors(req, res)) return 42 if (areValidationErrors(req, res)) return
30 43
@@ -36,5 +49,6 @@ const userHistoryRemoveValidator = [
36 49
37export { 50export {
38 userHistoryListValidator, 51 userHistoryListValidator,
39 userHistoryRemoveValidator 52 userHistoryRemoveElementValidator,
53 userHistoryRemoveAllValidator
40} 54}