import { Body , Controller , Delete , Get , Param , Patch , Post , Query , } from '@nestjs/common' ; import type { CatDTO } from './cat.dto' ; import { Cat } from './cat.entity' ; import { CatService } from './cat.service' ; @ Controller ( 'cat' ) export class CatController { constructor ( private readonly catService ) { } @ Get ( ) async getCats ( ) { return this . catService . getAll ( ) ; } @ Get ( '/name' ) async getByName ( @ Query ( 'name' ) name ) { return this . catService . getOneByName ( name ) ; } @ Get ( '/:id' ) async getById ( @ Param ( 'id' ) id ) { return this . catService . getOne ( id ) ; } @ Post ( '/new' ) async newCat ( @ Body ( ) cat ) { return this . catService . insertOne ( cat ) ; } @ Patch ( '/update' ) async updateCat ( @ Body ( ) cat ) { return this . catService . updateOne ( cat ) ; } @ Delete ( '/delete/:id' ) async deleteCat ( @ Param ( 'id' ) id ) { return this . catService . deleteOne ( id ) ; } }