fix: convert query params to numbers for pagination

@Query() decorator always returns strings. Using Number() conversion
with fallback to defaults (page=1, limit=20) to prevent NaN errors
in Prisma findMany skip/take calculations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Thomas Reitz 2026-03-08 18:21:17 +01:00
parent 4d5d5bac88
commit bd00ea5e50
2 changed files with 12 additions and 6 deletions

View file

@ -33,10 +33,13 @@ export class TenantsController {
@UseGuards(RolesGuard)
@ApiOperation({ summary: 'Alle Mandanten auflisten (Admin)' })
async findAll(
@Query('page') page?: number,
@Query('limit') limit?: number,
@Query('page') page?: string,
@Query('limit') limit?: string,
) {
return this.tenantsService.findAll(page ?? 1, limit ?? 20);
return this.tenantsService.findAll(
Number(page) || 1,
Number(limit) || 20,
);
}
/**

View file

@ -42,10 +42,13 @@ export class UsersController {
@UseGuards(RolesGuard)
@ApiOperation({ summary: 'Alle Benutzer auflisten (Admin)' })
async findAll(
@Query('page') page?: number,
@Query('limit') limit?: number,
@Query('page') page?: string,
@Query('limit') limit?: string,
) {
return this.usersService.findAll(page ?? 1, limit ?? 20);
return this.usersService.findAll(
Number(page) || 1,
Number(limit) || 20,
);
}
/**