import { Body, Controller, Delete, Get, Inject, Param, ParseIntPipe, Patch, Post } from "@nestjs/common"; import type { CreateCustomerInput, UpdateCustomerInput } from "../../dtos/customer.dto.js"; import { CUSTOMER_SERVICE } from "./interfaces/customer-service.interface.js"; import type { ICustomerService } from "./interfaces/customer-service.interface.js"; @Controller("customers") export class CustomerController { constructor(@Inject(CUSTOMER_SERVICE) private readonly customerService: ICustomerService) {} @Get() findAll() { return this.customerService.findAll(); } @Get(":id") findOne(@Param("id", ParseIntPipe) id: number) { return this.customerService.findById({ id }); } @Post() create(@Body() body: CreateCustomerInput) { return this.customerService.create(body); } @Patch(":id") update(@Param("id", ParseIntPipe) id: number, @Body() body: UpdateCustomerInput) { return this.customerService.update({ id }, body); } @Delete(":id") remove(@Param("id", ParseIntPipe) id: number) { return this.customerService.delete({ id }); } }