mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-17 12:33:22 +00:00
fix optional chaining for files
This commit is contained in:
@@ -85,8 +85,9 @@ export class AuthController {
|
|||||||
): Promise<UserEntity> {
|
): Promise<UserEntity> {
|
||||||
const userId = req.user.id
|
const userId = req.user.id
|
||||||
|
|
||||||
return await this.commandBus.execute(new UpdateUserCommand(userId, body, files.avatar?.[0]))
|
return await this.commandBus.execute(new UpdateUserCommand(userId, body, files?.avatar?.[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
description: 'Sign in using email and password. Must have an account to do so.',
|
description: 'Sign in using email and password. Must have an account to do so.',
|
||||||
summary: 'Sign in using email and password. Must have an account to do so.',
|
summary: 'Sign in using email and password. Must have an account to do so.',
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ export class CardsController {
|
|||||||
@Body() body: UpdateCardDto
|
@Body() body: UpdateCardDto
|
||||||
): Promise<Card> {
|
): Promise<Card> {
|
||||||
return this.commandBus.execute(
|
return this.commandBus.execute(
|
||||||
new UpdateCardCommand(id, body, req.user.id, files.answerImg?.[0], files.questionImg?.[0])
|
new UpdateCardCommand(id, body, req.user.id, files?.answerImg?.[0], files?.questionImg?.[0])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ export class DecksController {
|
|||||||
remove(@Param('id') id: string, @Req() req): Promise<Deck> {
|
remove(@Param('id') id: string, @Req() req): Promise<Deck> {
|
||||||
return this.commandBus.execute(new DeleteDeckByIdCommand(id, req.user.id))
|
return this.commandBus.execute(new DeleteDeckByIdCommand(id, req.user.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
description: 'Retrieve paginated cards in a deck',
|
description: 'Retrieve paginated cards in a deck',
|
||||||
summary: 'Retrieve cards in a deck',
|
summary: 'Retrieve cards in a deck',
|
||||||
@@ -155,11 +156,12 @@ export class DecksController {
|
|||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@Req() req,
|
@Req() req,
|
||||||
@UploadedFiles()
|
@UploadedFiles()
|
||||||
files: { questionImg: Express.Multer.File[]; answerImg: Express.Multer.File[] },
|
@Body()
|
||||||
@Body() card: CreateCardDto
|
card: CreateCardDto,
|
||||||
|
files?: { questionImg: Express.Multer.File[]; answerImg: Express.Multer.File[] }
|
||||||
): Promise<Card> {
|
): Promise<Card> {
|
||||||
return this.commandBus.execute(
|
return this.commandBus.execute(
|
||||||
new CreateCardCommand(req.user.id, id, card, files.answerImg?.[0], files.questionImg?.[0])
|
new CreateCardCommand(req.user.id, id, card, files?.answerImg?.[0], files?.questionImg?.[0])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user