X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fsort.ts;h=8c27e82379bfbb2b09f04b1bd249ea859ab9f2f3;hb=566c125d6eee3bd907404523d94e1e0b5e403a46;hp=cdb809e75e80084d5f6774e4f21ba4159be89fee;hpb=1174a8479ab9ee47b3305d668fe757435057a298;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts index cdb809e75..8c27e8237 100644 --- a/server/middlewares/sort.ts +++ b/server/middlewares/sort.ts @@ -1,6 +1,5 @@ import * as express from 'express' -import 'express-validator' -import { SortType } from '../helpers/utils' +import { SortType } from '../models/utils' function setDefaultSort (req: express.Request, res: express.Response, next: express.NextFunction) { if (!req.query.sort) req.query.sort = '-createdAt' @@ -8,8 +7,14 @@ function setDefaultSort (req: express.Request, res: express.Response, next: expr return next() } +function setDefaultSearchSort (req: express.Request, res: express.Response, next: express.NextFunction) { + if (!req.query.sort) req.query.sort = '-match' + + return next() +} + function setBlacklistSort (req: express.Request, res: express.Response, next: express.NextFunction) { - let newSort: SortType = { sortModel: undefined, sortValue: undefined } + let newSort: SortType = { sortModel: undefined, sortValue: '' } if (!req.query.sort) req.query.sort = '-createdAt' @@ -33,5 +38,6 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex export { setDefaultSort, + setDefaultSearchSort, setBlacklistSort }