Spaces:
Runtime error
Runtime error
| import { UseGuards, Param, NotFoundException, Get, Controller } from '@nestjs/common'; | |
| import { CurrentUser } from '@/infra/auth/utils/current-user.decorator'; | |
| import { JwtPayload } from '@/infra/auth/utils/@types'; | |
| import { JwtAuthGuard } from '@/infra/auth/guards/jwt-auth.guard'; | |
| import { FavoriteImageUseCase } from '@/domain/alcremie/application/use-cases/cases/favorite-image/favorite-image'; | |
| interface FavoriteImageParams { | |
| imageId: string; | |
| } | |
| ('favorite') | |
| (JwtAuthGuard) | |
| export class FavoriteImageController { | |
| constructor(private readonly favoriteImageUseCase: FavoriteImageUseCase) {} | |
| (':imageId') | |
| async favoriteImage(() params: FavoriteImageParams, () user: JwtPayload) { | |
| const result = await this.favoriteImageUseCase.execute({ | |
| imageId: params.imageId, | |
| userId: user.sub, | |
| }); | |
| if (result.isLeft()) { | |
| throw new NotFoundException(); | |
| } | |
| return { | |
| isFavorite: result.value.isFavorite, | |
| }; | |
| } | |
| } | |