import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; import { CommandResult, ack } from './command-result'; import { UpdateProjectSettingsCommand } from './update-project-settings.command'; import { WriteAccess } from './write-access'; @CommandHandler(UpdateProjectSettingsCommand) export class UpdateProjectSettingsCommandHandler implements ICommandHandler { constructor(private readonly access: WriteAccess) {} async execute(command: UpdateProjectSettingsCommand): Promise { const project = await this.access.project(command.projectId); project.updateSettings(command.actorId, command.settings); await project.commitAndWait(); return ack(project); } }