Skip to content

Commit

Permalink
๐Ÿ”’ :: ์นดํ…Œ๊ณ ๋ฆฌ api ์–ด๋“œ๋ฏผ auth guard ์ ์šฉ
Browse files Browse the repository at this point in the history
  • Loading branch information
shine-jung committed Nov 22, 2023
1 parent 0dae094 commit 2ddafc5
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/category/category.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ import {
Param,
Post,
Put,
UseGuards,
} from '@nestjs/common';
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import {
ApiHeader,
ApiOkResponse,
ApiOperation,
ApiTags,
} from '@nestjs/swagger';
import { CategoryService } from './category.service';
import { Category } from 'src/entity/category.entity';
import { CommonResponseDto } from 'src/common/dto/common-response.dto';
import { createResponse } from 'src/common/utils/response.helper';
import { CreateCategoryDto } from './dto/create-category.dto';
import { CategoriesResponseDto } from './dto/category-response.dto';
import { CategoryListSwaggerDto } from './dto/swagger/category-response.swagger.dto';
import { AdminAuthGuard } from 'src/guards/admin-auth.guard';

@Controller('category')
@ApiTags('Category')
Expand All @@ -35,12 +42,16 @@ export class CategoryController {
return { categories };
}

// TODO: ADMIN ๊ถŒํ•œ ํ•„์š”
@Post()
@UseGuards(AdminAuthGuard)
@ApiOperation({
summary: '์นดํ…Œ๊ณ ๋ฆฌ ์ƒ์„ฑ',
description: '์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.',
})
@ApiHeader({
name: 'Authorization',
description: 'Bearer {JWT ํ† ํฐ}',
})
@ApiOkResponse({
description: '์นดํ…Œ๊ณ ๋ฆฌ ์ƒ์„ฑ ์„ฑ๊ณต',
type: Category,
Expand All @@ -52,12 +63,16 @@ export class CategoryController {
return createResponse(200, '์นดํ…Œ๊ณ ๋ฆฌ ์ƒ์„ฑ ์„ฑ๊ณต', category.id);
}

// TODO: ADMIN ๊ถŒํ•œ ํ•„์š”
@Put(':id')
@UseGuards(AdminAuthGuard)
@ApiOperation({
summary: '์นดํ…Œ๊ณ ๋ฆฌ ์ˆ˜์ •',
description: '์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ์ˆ˜์ •ํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.',
})
@ApiHeader({
name: 'Authorization',
description: 'Bearer {JWT ํ† ํฐ}',
})
@ApiOkResponse({
description: '์นดํ…Œ๊ณ ๋ฆฌ ์ˆ˜์ • ์„ฑ๊ณต',
type: Category,
Expand All @@ -70,12 +85,16 @@ export class CategoryController {
return createResponse(200, '์นดํ…Œ๊ณ ๋ฆฌ ์ˆ˜์ • ์„ฑ๊ณต', id);
}

// TODO: ADMIN ๊ถŒํ•œ ํ•„์š”
@Delete(':id')
@UseGuards(AdminAuthGuard)
@ApiOperation({
summary: '์นดํ…Œ๊ณ ๋ฆฌ ์‚ญ์ œ',
description: '์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ์‚ญ์ œํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.',
})
@ApiHeader({
name: 'Authorization',
description: 'Bearer {JWT ํ† ํฐ}',
})
@ApiOkResponse({
description: '์นดํ…Œ๊ณ ๋ฆฌ ์‚ญ์ œ ์„ฑ๊ณต',
type: Category,
Expand Down

0 comments on commit 2ddafc5

Please sign in to comment.