mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-16 20:59:26 +00:00
16 lines
515 B
TypeScript
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)
|
|
}
|
|
}
|