feat: add delete current user account use case

This commit is contained in:
2024-07-26 11:49:50 +02:00
parent f697747124
commit 70bed1c1bb
3 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'
import { UsersRepository } from '../../users/infrastructure/users.repository'
export class DeleteCurrentAccountCommand {
constructor(public readonly userId: string) {}
}
@CommandHandler(DeleteCurrentAccountCommand)
export class DeleteCurrentUserAccountHandler
implements ICommandHandler<DeleteCurrentAccountCommand>
{
constructor(private readonly usersRepository: UsersRepository) {}
async execute(command: DeleteCurrentAccountCommand): Promise<boolean> {
return await this.usersRepository.deleteUserById(command.userId)
}
}