feat(api): add team management module with CRUD endpoints (#564)
All checks were successful
ci/woodpecker/push/api Pipeline was successful
All checks were successful
ci/woodpecker/push/api Pipeline was successful
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #564.
This commit is contained in:
51
apps/api/src/teams/teams.controller.ts
Normal file
51
apps/api/src/teams/teams.controller.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { Body, Controller, Delete, Get, Param, Post, UseGuards } from "@nestjs/common";
|
||||
import { AuthGuard } from "../auth/guards/auth.guard";
|
||||
import { PermissionGuard, WorkspaceGuard } from "../common/guards";
|
||||
import { Permission, RequirePermission, Workspace } from "../common/decorators";
|
||||
import { CreateTeamDto } from "./dto/create-team.dto";
|
||||
import { ManageTeamMemberDto } from "./dto/manage-team-member.dto";
|
||||
import { TeamsService } from "./teams.service";
|
||||
|
||||
@Controller("workspaces/:workspaceId/teams")
|
||||
@UseGuards(AuthGuard, WorkspaceGuard, PermissionGuard)
|
||||
export class TeamsController {
|
||||
constructor(private readonly teamsService: TeamsService) {}
|
||||
|
||||
@Post()
|
||||
@RequirePermission(Permission.WORKSPACE_ADMIN)
|
||||
async create(@Body() createTeamDto: CreateTeamDto, @Workspace() workspaceId: string) {
|
||||
return this.teamsService.create(workspaceId, createTeamDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@RequirePermission(Permission.WORKSPACE_ANY)
|
||||
async findAll(@Workspace() workspaceId: string) {
|
||||
return this.teamsService.findAll(workspaceId);
|
||||
}
|
||||
|
||||
@Post(":teamId/members")
|
||||
@RequirePermission(Permission.WORKSPACE_ADMIN)
|
||||
async addMember(
|
||||
@Param("teamId") teamId: string,
|
||||
@Body() dto: ManageTeamMemberDto,
|
||||
@Workspace() workspaceId: string
|
||||
) {
|
||||
return this.teamsService.addMember(workspaceId, teamId, dto);
|
||||
}
|
||||
|
||||
@Delete(":teamId/members/:userId")
|
||||
@RequirePermission(Permission.WORKSPACE_ADMIN)
|
||||
async removeMember(
|
||||
@Param("teamId") teamId: string,
|
||||
@Param("userId") userId: string,
|
||||
@Workspace() workspaceId: string
|
||||
) {
|
||||
return this.teamsService.removeMember(workspaceId, teamId, userId);
|
||||
}
|
||||
|
||||
@Delete(":teamId")
|
||||
@RequirePermission(Permission.WORKSPACE_ADMIN)
|
||||
async remove(@Param("teamId") teamId: string, @Workspace() workspaceId: string) {
|
||||
return this.teamsService.remove(workspaceId, teamId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user