import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, } from '@nestjs/common'; import { ProductsService } from './products.service'; import { CreateProductDto } from './dto/create-product.dto'; import { UpdateProductDto } from './dto/update-product.dto'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { Product } from './entities/product.entity'; import { DeleteResult, UpdateResult } from 'typeorm'; @Controller('products') export class ProductsController { constructor(private readonly productsService: ProductsService) {} @UseGuards(JwtAuthGuard) @Post() create(@Body() createProductDto: CreateProductDto): Promise { return this.productsService.create(createProductDto); } @Get() findAll(): Promise { return this.productsService.findAll(); } @Get(':id') findOne(@Param('id') id: string): Promise { return this.productsService.findOne(id); } @UseGuards(JwtAuthGuard) @Patch(':id') update( @Param('id') id: string, @Body() updateProductDto: UpdateProductDto, ): Promise { return this.productsService.update(id, updateProductDto); } @UseGuards(JwtAuthGuard) @Delete(':id') remove(@Param('id') id: string): Promise { return this.productsService.remove(id); } }