aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-03-11 14:39:28 +0100
committerChocobozzz <me@florianbigard.com>2020-03-11 15:02:20 +0100
commit764a965778ac89e027fd05dd35697c6763e0dc18 (patch)
treeecc18834566b940c729a57b5bf0d088e894f03d3 /server/middlewares/validators
parentfab6746354f9d9cb65c35d8bd9352c4b773b4c69 (diff)
downloadPeerTube-764a965778ac89e027fd05dd35697c6763e0dc18.tar.gz
PeerTube-764a965778ac89e027fd05dd35697c6763e0dc18.tar.zst
PeerTube-764a965778ac89e027fd05dd35697c6763e0dc18.zip
Implement pagination for overviews endpoint
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/videos/videos.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 96e0d6600..3a7869354 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -29,7 +29,7 @@ import {
29} from '../../../helpers/custom-validators/videos' 29} from '../../../helpers/custom-validators/videos'
30import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils' 30import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils'
31import { logger } from '../../../helpers/logger' 31import { logger } from '../../../helpers/logger'
32import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' 32import { CONSTRAINTS_FIELDS, OVERVIEWS } from '../../../initializers/constants'
33import { authenticatePromiseIfNeeded } from '../../oauth' 33import { authenticatePromiseIfNeeded } from '../../oauth'
34import { areValidationErrors } from '../utils' 34import { areValidationErrors } from '../utils'
35import { cleanUpReqFiles } from '../../../helpers/express-utils' 35import { cleanUpReqFiles } from '../../../helpers/express-utils'
@@ -301,6 +301,19 @@ const videosAcceptChangeOwnershipValidator = [
301 } 301 }
302] 302]
303 303
304const videosOverviewValidator = [
305 query('page')
306 .optional()
307 .isInt({ min: 1, max: OVERVIEWS.VIDEOS.SAMPLES_COUNT })
308 .withMessage('Should have a valid pagination'),
309
310 (req: express.Request, res: express.Response, next: express.NextFunction) => {
311 if (areValidationErrors(req, res)) return
312
313 return next()
314 }
315]
316
304function getCommonVideoEditAttributes () { 317function getCommonVideoEditAttributes () {
305 return [ 318 return [
306 body('thumbnailfile') 319 body('thumbnailfile')
@@ -442,7 +455,9 @@ export {
442 455
443 getCommonVideoEditAttributes, 456 getCommonVideoEditAttributes,
444 457
445 commonVideosFiltersValidator 458 commonVideosFiltersValidator,
459
460 videosOverviewValidator
446} 461}
447 462
448// --------------------------------------------------------------------------- 463// ---------------------------------------------------------------------------