Skip to content

Commit

Permalink
refactor: UserController 정리하고 Swagger 병합
Browse files Browse the repository at this point in the history
  • Loading branch information
w8385 committed May 25, 2024
1 parent e781410 commit a42cd8e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/common/configs/swagger.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const apiSwaggerConfig = (app: INestApplication) => {
.build();

const document = SwaggerModule.createDocument(app, config, {
include: [GroupModule, MemberModule, EventModule, TransactionModule],
include: [GroupModule, MemberModule, EventModule, TransactionModule, UserModule],
});
SwaggerModule.setup('api', app, document);
};
Expand Down
47 changes: 2 additions & 45 deletions src/user/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,15 @@
import { Body, Controller, Delete, Get, Param, Patch, Post, Request, UseGuards } from '@nestjs/common';
import { Controller, Get, Request, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';

import { AuthGuard } from '../auth/auth.guard';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { UserService } from './user.service';

@ApiTags('User')
@Controller('user')
export class UserController {
constructor(private readonly userService: UserService) {}

@Post()
create(@Body() createUserDto: CreateUserDto) {
return this.userService.create(createUserDto);
}

@Get()
findAll() {
return this.userService.getAll();
}

@UseGuards(AuthGuard)
@ApiBearerAuth('Authorization')
@Get('me')
me(@Request() req: any) {
return {
user: req.user,
userId: req.userId,
};
}

@Get(':userId')
findOne(@Param('userId') userId: string) {
return this.userService.getOne(userId);
}

@Get('kakao/:kakaoId')
findOneByKakaoId(@Param('kakaoId') kakaoId: string) {
return this.userService.getOneByKakaoId(kakaoId);
}

@Patch(':userId')
update(@Param('userId') userId: string, @Body() updateUserDto: UpdateUserDto) {
return this.userService.update(userId, updateUserDto);
}

@Delete()
removeAll() {
return this.userService.deleteAll();
}

@Delete(':userId')
remove(@Param('userId') userId: string) {
return this.userService.delete(userId);
return req.user;
}
}

0 comments on commit a42cd8e

Please sign in to comment.