import { Body , ClassSerializerInterceptor , Controller , Delete , Get , Param , Post , Render , UseGuards , UseInterceptors , } from '@nestjs/common' ; import { AuthGuard } from '@nestjs/passport' ; import { ApiBearerAuth , ApiUseTags } from '@nestjs/swagger' ; import { EntityManager , Transaction , TransactionManager } from 'typeorm' ; import { CreateCatDto } from '../../dtos/cat.dto' ; import { CatEntity } from '../../entities/cat.entity' ; import { CatsService } from './cats.service' ; @ ApiUseTags ( 'cats' ) @ ApiBearerAuth ( ) @ Controller ( 'cats' ) @ UseGuards ( AuthGuard ( ) ) export class CatsController { constructor ( private readonly catsService ) { } @ Get ( 'page' ) @ Render ( 'catsPage' ) getCatsPage ( ) { return this . catsService . getCats ( ) ; } @ Get ( ':id' ) @ UseInterceptors ( ClassSerializerInterceptor ) findOne ( @ Param ( 'id' ) id ) { return this . catsService . getCat ( id ) ; } @ Post ( ) create ( @ Body ( ) createCatDto ) { return this . catsService . createCat ( createCatDto ) ; } @ Delete ( ':name' ) @ Transaction ( ) delete ( @ Param ( 'name' ) name , @ TransactionManager ( ) manager ) { return this . catsService . deleteCat ( name , manager ) ; } }