Files
flashcards-api/src/modules/cards/use-cases/get-deck-by-id-use-case.ts
2023-06-18 12:16:03 +02:00

16 lines
515 B
TypeScript

import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'
import { CardsRepository } from '../infrastructure/cards.repository'
export class GetDeckByIdCommand {
constructor(public readonly id: string) {}
}
@CommandHandler(GetDeckByIdCommand)
export class GetDeckByIdHandler implements ICommandHandler<GetDeckByIdCommand> {
constructor(private readonly deckRepository: CardsRepository) {}
async execute(command: GetDeckByIdCommand) {
return await this.deckRepository.findDeckById(command.id)
}
}