X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fsort.ts;h=5120804b3a34b27dc88753ff86cffd5906062ff9;hb=299474e8279675adb6c5ce140e7e39c6f3439453;hp=cdb809e75e80084d5f6774e4f21ba4159be89fee;hpb=1174a8479ab9ee47b3305d668fe757435057a298;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts index cdb809e75..5120804b3 100644 --- a/server/middlewares/sort.ts +++ b/server/middlewares/sort.ts @@ -8,8 +8,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 +39,6 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex export { setDefaultSort, + setDefaultSearchSort, setBlacklistSort }