]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/controllers/api/video-channel.ts
Video channel API routes refractor
[github/Chocobozzz/PeerTube.git] / server / controllers / api / video-channel.ts
CommitLineData
48dce1c9
C
1import * as express from 'express'
2import { getFormattedObjects } from '../../helpers/utils'
3import {
4 asyncMiddleware,
5 paginationValidator,
6 setDefaultPagination,
7 setDefaultSort,
8 videoChannelsSortValidator
9} from '../../middlewares'
10import { VideoChannelModel } from '../../models/video/video-channel'
11
12const videoChannelRouter = express.Router()
13
14videoChannelRouter.get('/',
15 paginationValidator,
16 videoChannelsSortValidator,
17 setDefaultSort,
18 setDefaultPagination,
19 asyncMiddleware(listVideoChannels)
20)
21
22// ---------------------------------------------------------------------------
23
24export {
25 videoChannelRouter
26}
27
28// ---------------------------------------------------------------------------
29
30async function listVideoChannels (req: express.Request, res: express.Response, next: express.NextFunction) {
31 const resultList = await VideoChannelModel.listForApi(req.query.start, req.query.count, req.query.sort)
32
33 return res.json(getFormattedObjects(resultList.data, resultList.total))
34}