mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -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');
|
const response = await applicationRequest.get('/applications');
|
||||||
expect(response.status).toEqual(200);
|
expect(response.status).toEqual(200);
|
||||||
expect(response.body).toEqual([mockApplication]);
|
expect(response.body).toEqual([mockApplication]);
|
||||||
expect(response.header).toHaveProperty('total-number', '10');
|
expect(response.header).not.toHaveProperty('total-number');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('POST /applications', async () => {
|
it('POST /applications', async () => {
|
||||||
|
|
|
@ -38,10 +38,16 @@ export default function applicationRoutes<T extends AuthedRouter>(
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/applications',
|
'/applications',
|
||||||
koaPagination(),
|
koaPagination({ isOptional: true }),
|
||||||
koaGuard({ response: z.array(Applications.guard), status: 200 }),
|
koaGuard({ response: z.array(Applications.guard), status: 200 }),
|
||||||
async (ctx, next) => {
|
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([
|
const [{ count }, applications] = await Promise.all([
|
||||||
findTotalNumberOfApplications(),
|
findTotalNumberOfApplications(),
|
||||||
|
|
Loading…
Reference in a new issue