diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-24 17:05:32 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-24 17:12:57 +0200 |
commit | 48dce1c90dff4e90a4bcffefaecf157336cf904b (patch) | |
tree | 478de23812d0bfd93f47e9ad6ad8888c9edcc235 /server/controllers/api/video-channel.ts | |
parent | 82e392f8a42a19815e932dd386e96e61ebe6d191 (diff) | |
download | PeerTube-48dce1c90dff4e90a4bcffefaecf157336cf904b.tar.gz PeerTube-48dce1c90dff4e90a4bcffefaecf157336cf904b.tar.zst PeerTube-48dce1c90dff4e90a4bcffefaecf157336cf904b.zip |
Update video channel routes
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r-- | server/controllers/api/video-channel.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts new file mode 100644 index 000000000..d57273747 --- /dev/null +++ b/server/controllers/api/video-channel.ts | |||
@@ -0,0 +1,34 @@ | |||
1 | import * as express from 'express' | ||
2 | import { getFormattedObjects } from '../../helpers/utils' | ||
3 | import { | ||
4 | asyncMiddleware, | ||
5 | paginationValidator, | ||
6 | setDefaultPagination, | ||
7 | setDefaultSort, | ||
8 | videoChannelsSortValidator | ||
9 | } from '../../middlewares' | ||
10 | import { VideoChannelModel } from '../../models/video/video-channel' | ||
11 | |||
12 | const videoChannelRouter = express.Router() | ||
13 | |||
14 | videoChannelRouter.get('/', | ||
15 | paginationValidator, | ||
16 | videoChannelsSortValidator, | ||
17 | setDefaultSort, | ||
18 | setDefaultPagination, | ||
19 | asyncMiddleware(listVideoChannels) | ||
20 | ) | ||
21 | |||
22 | // --------------------------------------------------------------------------- | ||
23 | |||
24 | export { | ||
25 | videoChannelRouter | ||
26 | } | ||
27 | |||
28 | // --------------------------------------------------------------------------- | ||
29 | |||
30 | async 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 | } | ||