This commit is contained in:
2025-07-23 14:26:31 +09:00
parent afa9c4fe39
commit a3f591ab3a
35 changed files with 210 additions and 64 deletions

View File

@@ -1,16 +1,16 @@
import { AuthService } from './auth.service';
import { CreateUserDto } from 'src/users/dto/create-user.dto';
import { LoginUserDto } from 'src/auth/dto/login-user.dto';
import { SuccessResponseDto } from 'src/common/dto/sucees-response.dto';
import { LoginResponseDto } from './dto/login-response.dto';
import { UsersService } from 'src/users/users.service';
import { UserInfoResponseDto } from 'src/users/dto/user-info-response.dto';
import { AuthRequest } from 'src/common/interfaces/auth-request.interface';
import { CreateUserResponse } from 'src/users/dto/create-user-response.dto';
export declare class AuthController {
private readonly authService;
private userService;
constructor(authService: AuthService, userService: UsersService);
signup(dto: CreateUserDto): Promise<SuccessResponseDto>;
login(dto: LoginUserDto): Promise<SuccessResponseDto<LoginResponseDto>>;
getMe(req: AuthRequest): Promise<SuccessResponseDto<UserInfoResponseDto>>;
signup(dto: CreateUserDto): Promise<CreateUserResponse>;
login(dto: LoginUserDto): Promise<LoginResponseDto>;
getMe(req: AuthRequest): Promise<UserInfoResponseDto>;
}

View File

@@ -13,13 +13,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthController = void 0;
const openapi = require("@nestjs/swagger");
const common_1 = require("@nestjs/common");
const auth_service_1 = require("./auth.service");
const create_user_dto_1 = require("../users/dto/create-user.dto");
const login_user_dto_1 = require("./dto/login-user.dto");
const sucees_response_dto_1 = require("../common/dto/sucees-response.dto");
const login_response_dto_1 = require("./dto/login-response.dto");
const users_service_1 = require("../users/users.service");
const jwt_auth_guard_1 = require("./jwt-auth.guard");
const user_info_response_dto_1 = require("../users/dto/user-info-response.dto");
const swagger_1 = require("@nestjs/swagger");
const create_user_response_dto_1 = require("../users/dto/create-user-response.dto");
let AuthController = class AuthController {
authService;
userService;
@@ -28,21 +32,25 @@ let AuthController = class AuthController {
this.userService = userService;
}
async signup(dto) {
await this.authService.signup(dto);
return sucees_response_dto_1.SuccessResponseDto.ok();
const user = await this.authService.signup(dto);
return {
name: user.name,
email: user.email,
};
}
async login(dto) {
const loginUser = await this.authService.login(dto);
return sucees_response_dto_1.SuccessResponseDto.of(loginUser);
return await this.authService.login(dto);
}
async getMe(req) {
const userInfo = await this.userService.findUserInfoByIdOrFail(req.user.userId);
return sucees_response_dto_1.SuccessResponseDto.of(userInfo);
return await this.userService.findUserInfoByIdOrFail(req.user.userId);
}
};
exports.AuthController = AuthController;
__decorate([
(0, common_1.Post)('signup'),
(0, swagger_1.ApiOperation)({ summary: '회원가입' }),
(0, swagger_1.ApiOkResponse)({ description: '성공', type: create_user_response_dto_1.CreateUserResponse }),
openapi.ApiResponse({ status: 201, type: require("../users/dto/create-user-response.dto").CreateUserResponse }),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [create_user_dto_1.CreateUserDto]),
@@ -50,6 +58,9 @@ __decorate([
], AuthController.prototype, "signup", null);
__decorate([
(0, common_1.Post)('login'),
(0, swagger_1.ApiOperation)({ summary: '로그인' }),
(0, swagger_1.ApiOkResponse)({ description: '성공', type: login_response_dto_1.LoginResponseDto }),
openapi.ApiResponse({ status: 201, type: require("./dto/login-response.dto").LoginResponseDto }),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [login_user_dto_1.LoginUserDto]),
@@ -58,12 +69,16 @@ __decorate([
__decorate([
(0, common_1.Get)('me'),
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
(0, swagger_1.ApiOkResponse)({ description: '성공', type: user_info_response_dto_1.UserInfoResponseDto }),
openapi.ApiResponse({ status: 200, type: require("../users/dto/user-info-response.dto").UserInfoResponseDto }),
__param(0, (0, common_1.Request)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "getMe", null);
exports.AuthController = AuthController = __decorate([
(0, swagger_1.ApiTags)('인증'),
(0, common_1.Controller)('auth'),
__metadata("design:paramtypes", [auth_service_1.AuthService,
users_service_1.UsersService])

View File

@@ -1 +1 @@
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../src/auth/auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiF;AACjF,iDAA6C;AAC7C,kEAA8D;AAC9D,yDAA2D;AAC3D,2EAAwE;AAExE,0DAAuD;AACvD,qDAAgD;AAKzC,IAAM,cAAc,GAApB,MAAM,cAAc;IAEN;IACT;IAFV,YACmB,WAAwB,EACjC,WAAyB;QADhB,gBAAW,GAAX,WAAW,CAAa;QACjC,gBAAW,GAAX,WAAW,CAAc;IAChC,CAAC;IAGE,AAAN,KAAK,CAAC,MAAM,CAAS,GAAkB;QACrC,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,wCAAkB,CAAC,EAAE,EAAE,CAAC;IACjC,CAAC;IAGK,AAAN,KAAK,CAAC,KAAK,CAAS,GAAiB;QACnC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpD,OAAO,wCAAkB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAIK,AAAN,KAAK,CAAC,KAAK,CAAY,GAAgB;QACrC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChF,OAAO,wCAAkB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AAxBY,wCAAc;AAOnB;IADL,IAAA,aAAI,EAAC,QAAQ,CAAC;IACD,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,+BAAa;;4CAGtC;AAGK;IADL,IAAA,aAAI,EAAC,OAAO,CAAC;IACD,WAAA,IAAA,a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I,EAAC,QAAQ,CAAC;IACd,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACjC,IAAA,uBAAa,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,6CAAkB,EAAE,CAAC;;IACjD,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,+BAAa;;4CAMtC;AAKK;IAHL,IAAA,aAAI,EAAC,OAAO,CAAC;IACb,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAChC,IAAA,uBAAa,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,qCAAgB,EAAE,CAAC;;IAChD,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,6BAAY;;2CAEpC;AAMK;IAJL,IAAA,YAAG,EAAC,IAAI,CAAC;IACT,IAAA,kBAAS,EAAC,6BAAY,CAAC;IACvB,IAAA,uBAAa,GAAE;IACf,IAAA,uBAAa,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,4CAAmB,EAAE,CAAC;;IACnD,WAAA,IAAA,gBAAO,GAAE,CAAA;;;;2CAErB;yBA9BU,cAAc;IAF1B,IAAA,iBAAO,EAAC,IAAI,CAAC;IACb,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAGe,0BAAW;QACpB,4BAAY;GAHxB,cAAc,CA+B1B"}

View File

@@ -1,9 +1,39 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoginResponseDto = void 0;
const openapi = require("@nestjs/swagger");
const swagger_1 = require("@nestjs/swagger");
const user_info_response_dto_1 = require("../../users/dto/user-info-response.dto");
class LoginResponseDto {
access_token;
user;
static _OPENAPI_METADATA_FACTORY() {
return { access_token: { required: true, type: () => String }, user: { required: true, type: () => require("../../users/dto/user-info-response.dto").UserInfoResponseDto } };
}
}
exports.LoginResponseDto = LoginResponseDto;
__decorate([
(0, swagger_1.ApiProperty)({ description: '토큰', example: 'eyJsfFdfdDSddss...' }),
__metadata("design:type", String)
], LoginResponseDto.prototype, "access_token", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
description: '사용자 정보',
example: {
id: '1',
name: 'username',
email: 'user@email.com',
},
}),
__metadata("design:type", user_info_response_dto_1.UserInfoResponseDto)
], LoginResponseDto.prototype, "user", void 0);
//# sourceMappingURL=login-response.dto.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"login-response.dto.js","sourceRoot":"","sources":["../../../src/auth/dto/login-response.dto.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAgB;IAC3B,YAAY,CAAS;IACrB,IAAI,CAAsB;CAC3B;AAHD,4CAGC"}
{"version":3,"file":"login-response.dto.js","sourceRoot":"","sources":["../../../src/auth/dto/login-response.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,mFAA2E;AAE3E,MAAa,gBAAgB;IAE3B,YAAY,CAAS;IAUrB,IAAI,CAAsB;;;;CAC3B;AAbD,4CAaC;AAXC;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;;sDAC7C;AAUrB;IARC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,QAAQ;QACrB,OAAO,EAAE;YACP,EAAE,EAAE,GAAG;YACP,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,gBAAgB;SACxB;KACF,CAAC;8BACI,4CAAmB;8CAAC"}

View File

@@ -10,17 +10,24 @@ var __metadata = (this && this.__metadata) || function (k, v) {
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoginUserDto = void 0;
const openapi = require("@nestjs/swagger");
const swagger_1 = require("@nestjs/swagger");
const class_validator_1 = require("class-validator");
class LoginUserDto {
name;
password;
static _OPENAPI_METADATA_FACTORY() {
return { name: { required: true, type: () => String }, password: { required: true, type: () => String, minLength: 4 } };
}
}
exports.LoginUserDto = LoginUserDto;
__decorate([
(0, swagger_1.ApiProperty)({ description: '사용자 이름', example: 'username' }),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], LoginUserDto.prototype, "name", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: '비밀번호', example: 'password' }),
(0, class_validator_1.IsString)(),
(0, class_validator_1.MinLength)(4),
__metadata("design:type", String)

View File

@@ -1 +1 @@
{"version":3,"file":"login-user.dto.js","sourceRoot":"","sources":["../../../src/auth/dto/login-user.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAsD;AAEtD,MAAa,YAAY;IAEd,IAAI,CAAS;IAIb,QAAQ,CAAS;CAC3B;AAPD,oCAOC;AALU;IADR,IAAA,0BAAQ,GAAE;;0CACW;AAIb;IAFR,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;;8CACa"}
{"version":3,"file":"login-user.dto.js","sourceRoot":"","sources":["../../../src/auth/dto/login-user.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAsD;AAEtD,MAAa,YAAY;IAGd,IAAI,CAAS;IAKb,QAAQ,CAAS;;;;CAC3B;AATD,oCASC;AANU;IAFR,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAC3D,IAAA,0BAAQ,GAAE;;0CACW;AAKb;IAHR,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACzD,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,CAAC,CAAC;;8CACa"}