Newer
Older
import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete, UseGuards,

Lukáš Kratochvíl
committed
import { ApiTags } from '@nestjs/swagger';
import { CategoriesService } from './categories.service';
import { CreateCategoryDto } from './dto/create-category.dto';
import { UpdateCategoryDto } from './dto/update-category.dto';
import { CategoryEntity } from './entities/category.entity';
import {AuthorizationGuard} from "../../authorization/authorization.guard";
@ApiTags('categories')
@Controller('categories')
export class CategoriesController {
constructor(private readonly categoriesService: CategoriesService) {}
@UseGuards(AuthorizationGuard)
async create(
@Body() createCategoryDto: CreateCategoryDto,
): Promise<CategoryEntity> {
return await this.categoriesService.create(createCategoryDto);

Lukáš Kratochvíl
committed
async findAll(): Promise<CategoryEntity[]> {

Lukáš Kratochvíl
committed
async findOne(@Param('id') id: string): Promise<CategoryEntity> {
return await this.categoriesService.findOne(id);
@UseGuards(AuthorizationGuard)
async update(
@Param('id') id: string,
@Body() updateCategoryDto: UpdateCategoryDto,
): Promise<CategoryEntity> {
return await this.categoriesService.update(id, updateCategoryDto);
@UseGuards(AuthorizationGuard)

Lukáš Kratochvíl
committed
async remove(@Param('id') id: string): Promise<CategoryEntity> {
return await this.categoriesService.remove(id);