Skip to content

Commit

Permalink
feat: adds query search param for users list
Browse files Browse the repository at this point in the history
  • Loading branch information
rubvalave committed Apr 13, 2022
1 parent 770b39a commit 1a6abdf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/apps/api/src/modules/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ParseUUIDPipe,
Patch,
Post,
Query,
Request,
UseGuards,
ValidationPipe,
Expand Down Expand Up @@ -83,13 +84,18 @@ export class UsersController {
async findAll(
@ProcessFetchSpecification() fetchSpecification: FetchSpecification,
@Request() req: RequestWithAuthenticatedUser,
@Query('q') namesSearch?: string,
): Promise<User[]> {
//Admin-only endpoint so it needs a prior platformAdmin check.
if (!(await this.service.isPlatformAdmin(req.user.id))) {
throw new ForbiddenException();
}

const results = await this.service.findAllPaginated(fetchSpecification);
const results = await this.service.findAllPaginated(fetchSpecification, {
params: {
namesSearch,
},
});
return this.service.serialize(results.data, results.metadata);
}

Expand Down
1 change: 1 addition & 0 deletions api/apps/api/src/modules/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export class UsersService extends AppBaseService<
async extendFindAllResults(
entitiesAndCount: [User[], number],
_fetchSpecification?: FetchSpecification,
_info?: AppInfoDTO,
): Promise<[User[], number]> {
const extendedEntities: Promise<User>[] = entitiesAndCount[0].map(
(entity) => this.extendGetByIdResult(entity),
Expand Down

0 comments on commit 1a6abdf

Please sign in to comment.