0
Fork 0
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:
Xiao Yijun 2023-07-19 17:58:22 +08:00 committed by GitHub
parent 6e094d959f
commit 8dbc3f6b3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -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 () => {

View file

@ -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(),