add crete/get cards

This commit is contained in:
2023-06-18 12:16:03 +02:00
parent 0794238f0d
commit ca976cfe5d
19 changed files with 358 additions and 7 deletions

View File

@@ -0,0 +1,29 @@
import { Body, Controller, Delete, Get, Param, Patch, Req, UseGuards } from '@nestjs/common'
import { CardsService } from './cards.service'
import { UpdateCardDto } from './dto/update-card.dto'
import { CommandBus } from '@nestjs/cqrs'
import { DeleteDeckByIdCommand, GetDeckByIdCommand, UpdateDeckCommand } from './use-cases'
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'
@Controller('cards')
export class CardsController {
constructor(private readonly decksService: CardsService, private commandBus: CommandBus) {}
@UseGuards(JwtAuthGuard)
@Get(':id')
findOne(@Param('id') id: string) {
return this.commandBus.execute(new GetDeckByIdCommand(id))
}
@UseGuards(JwtAuthGuard)
@Patch(':id')
update(@Param('id') id: string, @Body() updateDeckDto: UpdateCardDto, @Req() req) {
return this.commandBus.execute(new UpdateDeckCommand(id, updateDeckDto, req.user.id))
}
@UseGuards(JwtAuthGuard)
@Delete(':id')
remove(@Param('id') id: string, @Req() req) {
return this.commandBus.execute(new DeleteDeckByIdCommand(id, req.user.id))
}
}