]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/sort.ts
Remove ng2-completer
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / sort.ts
index ebc7333c7c07a88104474b55dac130c42981fd20..3baee9fb3df437236e675b0d4223f2fe61c26721 100644 (file)
@@ -1,3 +1,6 @@
+import 'express-validator'
+import * as express from 'express'
+
 import { checkErrors } from './utils'
 import { logger } from '../../helpers'
 import { SORTABLE_COLUMNS } from '../../initializers'
@@ -7,15 +10,15 @@ const SORTABLE_USERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USERS)
 const SORTABLE_VIDEO_ABUSES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_ABUSES)
 const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS)
 
-function usersSortValidator (req, res, next) {
+function usersSortValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
   checkSort(req, res, next, SORTABLE_USERS_COLUMNS)
 }
 
-function videoAbusesSortValidator (req, res, next) {
+function videoAbusesSortValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
   checkSort(req, res, next, SORTABLE_VIDEO_ABUSES_COLUMNS)
 }
 
-function videosSortValidator (req, res, next) {
+function videosSortValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
   checkSort(req, res, next, SORTABLE_VIDEOS_COLUMNS)
 }
 
@@ -29,7 +32,7 @@ export {
 
 // ---------------------------------------------------------------------------
 
-function checkSort (req, res, next, sortableColumns) {
+function checkSort (req: express.Request, res: express.Response, next: express.NextFunction, sortableColumns: string[]) {
   req.checkQuery('sort', 'Should have correct sortable column').optional().isIn(sortableColumns)
 
   logger.debug('Checking sort parameters', { parameters: req.query })
@@ -37,7 +40,7 @@ function checkSort (req, res, next, sortableColumns) {
   checkErrors(req, res, next)
 }
 
-function createSortableColumns (sortableColumns) {
+function createSortableColumns (sortableColumns: string[]) {
   const sortableColumnDesc = sortableColumns.map(sortableColumn => '-' + sortableColumn)
 
   return sortableColumns.concat(sortableColumnDesc)