import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; import { CommandResult, ack } from './command-result'; import { RemoveProjectMemberCommand } from './remove-project-member.command'; import { WriteAccess } from './write-access'; @CommandHandler(RemoveProjectMemberCommand) export class RemoveProjectMemberCommandHandler implements ICommandHandler { constructor(private readonly access: WriteAccess) {} async execute(command: RemoveProjectMemberCommand): Promise { const project = await this.access.project(command.projectId); project.removeMember(command.actorId, command.userId); await project.commitAndWait(); return ack(project); } }