From 91b6631984fa7097bd60aa013d1cf041d7b95f58 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 May 2019 15:09:38 +0200 Subject: Add pagination to account video channels endpoint --- server/controllers/api/accounts.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts index 8d4db1e75..9b3489120 100644 --- a/server/controllers/api/accounts.ts +++ b/server/controllers/api/accounts.ts @@ -16,7 +16,8 @@ import { accountNameWithHostGetValidator, accountsSortValidator, ensureAuthUserOwnsAccountValidator, - videosSortValidator + videosSortValidator, + videoChannelsSortValidator } from '../../middlewares/validators' import { AccountModel } from '../../models/account/account' import { AccountVideoRateModel } from '../../models/account/account-video-rate' @@ -56,6 +57,10 @@ accountsRouter.get('/:accountName/videos', accountsRouter.get('/:accountName/video-channels', asyncMiddleware(accountNameWithHostGetValidator), + paginationValidator, + videoChannelsSortValidator, + setDefaultSort, + setDefaultPagination, asyncMiddleware(listAccountChannels) ) @@ -108,7 +113,14 @@ async function listAccounts (req: express.Request, res: express.Response) { } async function listAccountChannels (req: express.Request, res: express.Response) { - const resultList = await VideoChannelModel.listByAccount(res.locals.account.id) + const options = { + accountId: res.locals.account.id, + start: req.query.start, + count: req.query.count, + sort: req.query.sort, + } + + const resultList = await VideoChannelModel.listByAccount(options) return res.json(getFormattedObjects(resultList.data, resultList.total)) } -- cgit v1.2.3