X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fsort.ts;h=4588958988af88a759c35ebfbc7a6afb58ed0643;hb=453537426a4e172967320cfac4bb1f53c28d94f5;hp=75238228fefb229401a6ef7491beb39f5e7e097d;hpb=d5692d4088cdd9fde3be6ff34be8ce2816dab0cf;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts index 75238228f..458895898 100644 --- a/server/middlewares/sort.ts +++ b/server/middlewares/sort.ts @@ -1,21 +1,22 @@ -import * as express from 'express' +import express from 'express' import { SortType } from '../models/utils' const setDefaultSort = setDefaultSortFactory('-createdAt') +const setDefaultVideosSort = setDefaultSortFactory('-publishedAt') const setDefaultVideoRedundanciesSort = setDefaultSortFactory('name') const setDefaultSearchSort = setDefaultSortFactory('-match') function setBlacklistSort (req: express.Request, res: express.Response, next: express.NextFunction) { - let newSort: SortType = { sortModel: undefined, sortValue: '' } + const newSort: SortType = { sortModel: undefined, sortValue: '' } if (!req.query.sort) req.query.sort = '-createdAt' // Set model we want to sort onto if (req.query.sort === '-createdAt' || req.query.sort === 'createdAt' || req.query.sort === '-id' || req.query.sort === 'id') { - // If we want to sort onto the BlacklistedVideos relation, we won't specify it in the query parameter ... + // If we want to sort onto the BlacklistedVideos relation, we won't specify it in the query parameter... newSort.sortModel = undefined } else { newSort.sortModel = 'Video' @@ -33,6 +34,7 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex export { setDefaultSort, setDefaultSearchSort, + setDefaultVideosSort, setDefaultVideoRedundanciesSort, setBlacklistSort }