diff --git a/server/nest/src/auth/auth.controller.ts b/server/nest/src/auth/auth.controller.ts index 76d01a1..6bb44fa 100644 --- a/server/nest/src/auth/auth.controller.ts +++ b/server/nest/src/auth/auth.controller.ts @@ -60,12 +60,4 @@ export class AuthController { ); return { userId: user.user_id }; } - - @Delete() - @UseGuards(AuthGuard()) - @HttpCode(HTTP_STATUS_CODE.SUCCESS) - async deleteUser(@ReqUser() user: User): Promise<{ userId: string }> { - this.logger.log(`DELETE /users - nickname=${user.nickname}`); - return await this.authService.deleteUser(user); - } } diff --git a/server/nest/src/auth/auth.service.ts b/server/nest/src/auth/auth.service.ts index a3a2728..a9f548b 100644 --- a/server/nest/src/auth/auth.service.ts +++ b/server/nest/src/auth/auth.service.ts @@ -195,22 +195,4 @@ export class AuthService { return true; } - - async deleteUser(user: User): Promise<{ userId: string }> { - try { - await this.userRepository.deleteUser(user.user_id); - - return { userId: user.user_id }; - } catch (err) { - if (err instanceof CatchyException) { - throw err; - } - - throw new CatchyException( - 'SERVICE_ERROR', - HTTP_STATUS_CODE.SERVER_ERROR, - ERROR_CODE.SERVICE_ERROR, - ); - } - } } diff --git a/server/nest/src/user/user.controller.ts b/server/nest/src/user/user.controller.ts index e8f02b8..7a6124a 100644 --- a/server/nest/src/user/user.controller.ts +++ b/server/nest/src/user/user.controller.ts @@ -12,6 +12,7 @@ import { Logger, Put, ValidationPipe, + Delete, } from '@nestjs/common'; import { UserService } from './user.service'; import { HTTP_STATUS_CODE } from 'src/codes/httpStatusCode.enum'; @@ -48,6 +49,14 @@ export class UserController { }; } + @Delete() + @UseGuards(AuthGuard()) + @HttpCode(HTTP_STATUS_CODE.SUCCESS) + async deleteUser(@ReqUser() user: User): Promise<{ userId: string }> { + this.logger.log(`DELETE /users - nickname=${user.nickname}`); + return await this.userService.deleteUser(user); + } + @Get('duplicate/:name') @HttpCode(HTTP_STATUS_CODE.NOT_DUPLICATED_NICKNAME) async checkDuplicateNickname( diff --git a/server/nest/src/user/user.service.ts b/server/nest/src/user/user.service.ts index d6c13e0..5105eb1 100644 --- a/server/nest/src/user/user.service.ts +++ b/server/nest/src/user/user.service.ts @@ -41,6 +41,24 @@ export class UserService { } } + async deleteUser(user: User): Promise<{ userId: string }> { + try { + await this.userRepository.deleteUser(user.user_id); + + return { userId: user.user_id }; + } catch (err) { + if (err instanceof CatchyException) { + throw err; + } + + throw new CatchyException( + 'SERVICE_ERROR', + HTTP_STATUS_CODE.SERVER_ERROR, + ERROR_CODE.SERVICE_ERROR, + ); + } + } + async getRecentPlayedMusicByUserId( userId: string, count: number,