1
0
mirror of https://framagit.org/framasoft/peertube/search-index/ synced 2025-01-05 22:17:12 +01:00
sepia-search-motore-di-rice.../server/middlewares/sort.ts
2020-02-14 16:14:45 +01:00

23 lines
579 B
TypeScript

import * as express from 'express'
const setDefaultSort = setDefaultSortFactory('-createdAt')
const setDefaultSearchSort = setDefaultSortFactory('-match')
// ---------------------------------------------------------------------------
export {
setDefaultSort,
setDefaultSearchSort
}
// ---------------------------------------------------------------------------
function setDefaultSortFactory (sort: string) {
return (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (!req.query.sort) req.query.sort = sort
return next()
}
}