aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/index.ts1
-rw-r--r--server/middlewares/search.ts14
-rw-r--r--server/middlewares/validators/videos.ts11
3 files changed, 5 insertions, 21 deletions
diff --git a/server/middlewares/index.ts b/server/middlewares/index.ts
index aafcad2d9..0cef26953 100644
--- a/server/middlewares/index.ts
+++ b/server/middlewares/index.ts
@@ -4,6 +4,5 @@ export * from './async'
4export * from './oauth' 4export * from './oauth'
5export * from './pagination' 5export * from './pagination'
6export * from './servers' 6export * from './servers'
7export * from './search'
8export * from './sort' 7export * from './sort'
9export * from './user-right' 8export * from './user-right'
diff --git a/server/middlewares/search.ts b/server/middlewares/search.ts
deleted file mode 100644
index 6fe83d25b..000000000
--- a/server/middlewares/search.ts
+++ /dev/null
@@ -1,14 +0,0 @@
1import 'express-validator'
2import * as express from 'express'
3
4function setVideosSearch (req: express.Request, res: express.Response, next: express.NextFunction) {
5 if (!req.query.field) req.query.field = 'name'
6
7 return next()
8}
9
10// ---------------------------------------------------------------------------
11
12export {
13 setVideosSearch
14}
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index f21680aa0..10625e41d 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -18,7 +18,7 @@ import {
18} from '../../helpers/custom-validators/videos' 18} from '../../helpers/custom-validators/videos'
19import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils' 19import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils'
20import { logger } from '../../helpers/logger' 20import { logger } from '../../helpers/logger'
21import { CONSTRAINTS_FIELDS, SEARCHABLE_COLUMNS } from '../../initializers' 21import { CONSTRAINTS_FIELDS } from '../../initializers'
22import { database as db } from '../../initializers/database' 22import { database as db } from '../../initializers/database'
23import { UserInstance } from '../../models/account/user-interface' 23import { UserInstance } from '../../models/account/user-interface'
24import { VideoInstance } from '../../models/video/video-interface' 24import { VideoInstance } from '../../models/video/video-interface'
@@ -31,11 +31,11 @@ const videosAddValidator = [
31 + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME.join(', ') 31 + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME.join(', ')
32 ), 32 ),
33 body('name').custom(isVideoNameValid).withMessage('Should have a valid name'), 33 body('name').custom(isVideoNameValid).withMessage('Should have a valid name'),
34 body('category').custom(isVideoCategoryValid).withMessage('Should have a valid category'), 34 body('category').optional().custom(isVideoCategoryValid).withMessage('Should have a valid category'),
35 body('licence').custom(isVideoLicenceValid).withMessage('Should have a valid licence'), 35 body('licence').optional().custom(isVideoLicenceValid).withMessage('Should have a valid licence'),
36 body('language').optional().custom(isVideoLanguageValid).withMessage('Should have a valid language'), 36 body('language').optional().custom(isVideoLanguageValid).withMessage('Should have a valid language'),
37 body('nsfw').custom(isVideoNSFWValid).withMessage('Should have a valid NSFW attribute'), 37 body('nsfw').custom(isVideoNSFWValid).withMessage('Should have a valid NSFW attribute'),
38 body('description').custom(isVideoDescriptionValid).withMessage('Should have a valid description'), 38 body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'),
39 body('channelId').custom(isIdValid).withMessage('Should have correct video channel id'), 39 body('channelId').custom(isIdValid).withMessage('Should have correct video channel id'),
40 body('privacy').custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), 40 body('privacy').custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'),
41 body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'), 41 body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'),
@@ -172,8 +172,7 @@ const videosRemoveValidator = [
172] 172]
173 173
174const videosSearchValidator = [ 174const videosSearchValidator = [
175 param('value').not().isEmpty().withMessage('Should have a valid search'), 175 query('search').not().isEmpty().withMessage('Should have a valid search'),
176 query('field').optional().isIn(SEARCHABLE_COLUMNS.VIDEOS).withMessage('Should have correct searchable column'),
177 176
178 (req: express.Request, res: express.Response, next: express.NextFunction) => { 177 (req: express.Request, res: express.Response, next: express.NextFunction) => {
179 logger.debug('Checking videosSearch parameters', { parameters: req.params }) 178 logger.debug('Checking videosSearch parameters', { parameters: req.params })