You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
import { |
|
Controller, |
|
Get, |
|
Post, |
|
Body, |
|
Patch, |
|
Param, |
|
Delete, |
|
UseGuards, |
|
} from '@nestjs/common'; |
|
import { ProductsService } from './products.service'; |
|
import { CreateProductDto, UpdateProductDto } from './dto'; |
|
import { UUID } from 'crypto'; |
|
import { AuthGuard } from '@nestjs/passport'; |
|
|
|
@Controller('products') |
|
export class ProductsController { |
|
constructor(private readonly productsService: ProductsService) {} |
|
|
|
@UseGuards(AuthGuard('jwt')) |
|
@Post() |
|
create(@Body() createProductDto: CreateProductDto) { |
|
return this.productsService.create(createProductDto); |
|
} |
|
|
|
@Get() |
|
findAll() { |
|
return this.productsService.findAll(); |
|
} |
|
|
|
@Get(':id') |
|
findOne(@Param('id') id: string) { |
|
return this.productsService.findOne(+id); |
|
} |
|
|
|
@UseGuards(AuthGuard('jwt')) |
|
@Patch(':id') |
|
update(@Param('id') id: string, @Body() updateProductDto: UpdateProductDto) { |
|
return this.productsService.update(+id, updateProductDto); |
|
} |
|
|
|
@UseGuards(AuthGuard('jwt')) |
|
@Delete(':id') |
|
remove(@Param('id') id: string) { |
|
return this.productsService.remove(+id); |
|
} |
|
}
|
|
|