diff --git a/apps/api/src/workspaces/workspaces.controller.ts b/apps/api/src/workspaces/workspaces.controller.ts index d2cad92..93ddef9 100644 --- a/apps/api/src/workspaces/workspaces.controller.ts +++ b/apps/api/src/workspaces/workspaces.controller.ts @@ -38,6 +38,16 @@ export class WorkspacesController { return this.workspacesService.getStats(workspaceId); } + /** + * GET /api/workspaces/:workspaceId/members + * Returns the list of members for a workspace. + */ + @Get(":workspaceId/members") + @UseGuards(WorkspaceGuard) + async getMembers(@Param("workspaceId") workspaceId: string) { + return this.workspacesService.getMembers(workspaceId); + } + /** * POST /api/workspaces/:workspaceId/members * Add a member to a workspace with the specified role. diff --git a/apps/api/src/workspaces/workspaces.service.ts b/apps/api/src/workspaces/workspaces.service.ts index 8aabd49..11dda14 100644 --- a/apps/api/src/workspaces/workspaces.service.ts +++ b/apps/api/src/workspaces/workspaces.service.ts @@ -321,6 +321,18 @@ export class WorkspacesService { }); } + /** + * Get members of a workspace. + */ + async getMembers(workspaceId: string) { + return this.prisma.workspaceMember.findMany({ + where: { workspaceId }, + include: { + user: { select: { id: true, name: true, email: true, createdAt: true } }, + }, + orderBy: { joinedAt: "asc" }, + }); + } private assertCanAssignRole( actorRole: WorkspaceMemberRole, requestedRole: WorkspaceMemberRole