Spaces:
Runtime error
Runtime error
File size: 925 Bytes
96ed566 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import {
UseGuards,
Param,
HttpCode,
Delete,
Controller,
BadRequestException,
} from '@nestjs/common';
import { Roles } from '@/infra/auth/utils/roles.decorator';
import { RoleGuard } from '@/infra/auth/guards/role.guard';
import { JwtAuthGuard } from '@/infra/auth/guards/jwt-auth.guard';
import { DeleteImageUseCase } from '@/domain/alcremie/application/use-cases/cases/delete-image/delete-image';
interface DeleteImageParams {
id: string;
}
@Controller('image')
@UseGuards(JwtAuthGuard, RoleGuard)
@Controller()
export class DeleteImageController {
constructor(private readonly deleteImageUseCase: DeleteImageUseCase) {}
@Delete(':id')
@Roles('ADMIN')
@HttpCode(204)
async deleteImage(@Param() params: DeleteImageParams) {
const result = await this.deleteImageUseCase.execute({
imageId: params.id,
});
if (result.isLeft()) {
throw new BadRequestException();
}
}
}
|