Spaces:
Runtime error
Runtime error
| import { z } from 'zod'; | |
| import { Param, Get, Controller, BadRequestException } from '@nestjs/common'; | |
| import { ImagePresenter } from '@/infra/http/presenters/image.presenter'; | |
| import { GetImageByIdUseCase } from '@/domain/alcremie/application/use-cases/cases/get-image-by-id/get-image-by-id'; | |
| const fetchImageParams = z.object({ | |
| id: z.string(), | |
| }); | |
| type FetchImageParams = z.infer<typeof fetchImageParams>; | |
| ('image/find') | |
| export class GetImageController { | |
| constructor(private readonly getImageByIdUseCase: GetImageByIdUseCase) {} | |
| (':id') | |
| async getImage(() params: FetchImageParams) { | |
| const result = await this.getImageByIdUseCase.execute({ | |
| id: params.id, | |
| }); | |
| if (result.isLeft()) { | |
| throw new BadRequestException(); | |
| } | |
| return { image: ImagePresenter.toHTTP(result.value.image) }; | |
| } | |
| } | |