mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-17 20:59:27 +00:00
add crete/get cards
This commit is contained in:
15
src/modules/cards/use-cases/get-deck-by-id-use-case.ts
Normal file
15
src/modules/cards/use-cases/get-deck-by-id-use-case.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user