1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Begin advanced search

This commit is contained in:
Chocobozzz 2018-07-19 16:17:54 +02:00
parent 7279b45581
commit 57c36b277e
38 changed files with 584 additions and 247 deletions

View file

@ -0,0 +1,43 @@
import * as express from 'express'
import { isNSFWHidden } from '../../helpers/express-utils'
import { getFormattedObjects } from '../../helpers/utils'
import { VideoModel } from '../../models/video/video'
import {
asyncMiddleware,
optionalAuthenticate,
paginationValidator,
searchValidator,
setDefaultPagination,
setDefaultSearchSort,
videosSearchSortValidator
} from '../../middlewares'
const searchRouter = express.Router()
searchRouter.get('/videos',
paginationValidator,
setDefaultPagination,
videosSearchSortValidator,
setDefaultSearchSort,
optionalAuthenticate,
searchValidator,
asyncMiddleware(searchVideos)
)
// ---------------------------------------------------------------------------
export { searchRouter }
// ---------------------------------------------------------------------------
async function searchVideos (req: express.Request, res: express.Response) {
const resultList = await VideoModel.searchAndPopulateAccountAndServer(
req.query.search as string,
req.query.start as number,
req.query.count as number,
req.query.sort as string,
isNSFWHidden(res)
)
return res.json(getFormattedObjects(resultList.data, resultList.total))
}