mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
feat(core): support fetching all applications without pagination (#4184)
This commit is contained in:
parent
6e094d959f
commit
8dbc3f6b3c
2 changed files with 9 additions and 3 deletions
|
@ -58,7 +58,7 @@ describe('application route', () => {
|
|||
const response = await applicationRequest.get('/applications');
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.body).toEqual([mockApplication]);
|
||||
expect(response.header).toHaveProperty('total-number', '10');
|
||||
expect(response.header).not.toHaveProperty('total-number');
|
||||
});
|
||||
|
||||
it('POST /applications', async () => {
|
||||
|
|
|
@ -38,10 +38,16 @@ export default function applicationRoutes<T extends AuthedRouter>(
|
|||
|
||||
router.get(
|
||||
'/applications',
|
||||
koaPagination(),
|
||||
koaPagination({ isOptional: true }),
|
||||
koaGuard({ response: z.array(Applications.guard), status: 200 }),
|
||||
async (ctx, next) => {
|
||||
const { limit, offset } = ctx.pagination;
|
||||
const { limit, offset, disabled: paginationDisabled } = ctx.pagination;
|
||||
|
||||
if (paginationDisabled) {
|
||||
ctx.body = await findAllApplications();
|
||||
|
||||
return next();
|
||||
}
|
||||
|
||||
const [{ count }, applications] = await Promise.all([
|
||||
findTotalNumberOfApplications(),
|
||||
|
|
Loading…
Reference in a new issue