From 6c1e3b53a7810ea5548c75c4957694fde00067d1 Mon Sep 17 00:00:00 2001 From: "Brian. Paik" Date: Wed, 31 Jul 2024 10:46:30 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B0=84=EB=8B=A8=ED=95=9C=20=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.controller.ts | 20 +++++++++++++- src/app.service.ts | 53 +++++++++++++++++++++++++++++++++++- src/common/configs/config.ts | 2 +- src/metadata.ts | 2 +- 4 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/app.controller.ts b/src/app.controller.ts index 5956c9f..2f2eadd 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -1,4 +1,10 @@ -import { Controller, Get, Param } from '@nestjs/common'; +import { + Controller, + Get, + HttpException, + HttpStatus, + Param, +} from '@nestjs/common'; import { AppService } from './app.service'; @Controller() @@ -10,6 +16,18 @@ export class AppController { return this.appService.getHello(); } + @Get('error-auth') + getErrorAuth(): any { + const errorResponse = this.appService.getErrorAuth(); + throw new HttpException( + { + status: HttpStatus.UNAUTHORIZED, + error: errorResponse, + }, + HttpStatus.UNAUTHORIZED, + ); + } + @Get('hello/:name') getHelloName(@Param('name') name: string): string { return this.appService.getHelloName(name); diff --git a/src/app.service.ts b/src/app.service.ts index 641629a..d498f4f 100644 --- a/src/app.service.ts +++ b/src/app.service.ts @@ -3,7 +3,58 @@ import { Injectable } from '@nestjs/common'; @Injectable() export class AppService { getHello(): string { - return 'Hello World!'; + return ` + + + + + + 파인 마켓 + + + +
+

파인 마켓의 메인 도메인 입니다.

+

Swagger

+

Client

+
+ + + `; + } + + getErrorAuth(): any { + return { + code: '40100003', + desc: '인증 실패 - CONFIRM KEY만료 ## ConfirmCode is not exist', + msg: '인증 실패 - CONFIRM KEY만료', + result: {}, + }; } getHelloName(name: string): string { diff --git a/src/common/configs/config.ts b/src/common/configs/config.ts index 8df11e0..95cdcf1 100644 --- a/src/common/configs/config.ts +++ b/src/common/configs/config.ts @@ -21,7 +21,7 @@ const config: Config = { sortSchema: true, }, security: { - expiresIn: '10m', + expiresIn: '3m', refreshIn: '7d', bcryptSaltOrRound: 10, }, diff --git a/src/metadata.ts b/src/metadata.ts index b72ba53..e5e2457 100644 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -4,5 +4,5 @@ export default async () => { ["./users/dto/response-user-dto"]: await import("./users/dto/response-user-dto"), ["./users/models/user.model"]: await import("./users/models/user.model") }; - return { "@nestjs/swagger/plugin": { "models": [[import("./posts/dto/pagenation-query.dto"), { "PaginationQueryDto": { page: { required: false, type: () => Number, default: 1, minimum: 1 }, limit: { required: false, type: () => Number, default: 10, minimum: 1 }, query: { required: false, type: () => String }, orderBy: { required: false, type: () => String }, direction: { required: false, type: () => Object, default: "asc" } } }]], "controllers": [[import("./app.controller"), { "AppController": { "getHello": { type: String }, "getHelloName": { type: String } } }], [import("./auth/auth.controller"), { "AuthController": { "signup": {}, "login": {}, "refreshToken": {}, "logout": {}, "getUser": { type: Object } } }], [import("./users/users.controller"), { "UserController": { "getProfile": { type: t["./users/dto/response-user-dto"].UserResponseDto }, "updateUser": { type: Object }, "changePassword": { type: Object } } }], [import("./posts/posts.controller"), { "PostsController": { "createPost": { type: Object }, "getPublishedPosts": {}, "getUserPosts": { type: [Object] }, "getPost": { type: Object } } }]] }, "@nestjs/graphql/plugin": { "models": [[import("./auth/dto/signup.input"), { "SignupInput": { email: {}, password: {}, username: { nullable: true } } }], [import("./auth/models/token.model"), { "Token": { accessToken: {}, refreshToken: {} } }], [import("./common/models/base.model"), { "BaseModel": { id: {}, createdAt: {}, updatedAt: {} } }], [import("./posts/models/post.model"), { "Post": { title: {}, content: { nullable: true }, published: {}, imgUrl: { nullable: true }, author: { nullable: true } } }], [import("./users/models/user.model"), { "User": { email: {}, username: { nullable: true }, role: {}, posts: { nullable: true } } }], [import("./auth/models/auth.model"), { "Auth": { user: { type: () => t["./users/models/user.model"].User } } }], [import("./auth/dto/login.input"), { "LoginInput": { email: {}, password: {} } }], [import("./auth/dto/refresh-token.input"), { "RefreshTokenInput": { token: {} } }], [import("./users/dto/change-password.input"), { "ChangePasswordInput": { oldPassword: {}, newPassword: {} } }], [import("./users/dto/update-user.input"), { "UpdateUserInput": { username: { nullable: true } } }], [import("./common/pagination/pagination.args"), { "PaginationArgs": { skip: { nullable: true, type: () => Number }, after: { nullable: true, type: () => String }, before: { nullable: true, type: () => String }, first: { nullable: true, type: () => Number }, last: { nullable: true, type: () => Number } } }], [import("./posts/args/post-id.args"), { "PostIdArgs": { postId: { type: () => String } } }], [import("./posts/args/user-id.args"), { "UserIdArgs": { userId: { type: () => String } } }], [import("./common/pagination/page-info.model"), { "PageInfo": { endCursor: { nullable: true }, hasNextPage: {}, hasPreviousPage: {}, startCursor: { nullable: true } } }], [import("./posts/models/post-connection.model"), { "PostConnection": {} }], [import("./posts/dto/post-order.input"), { "PostOrder": { field: {} } }], [import("./posts/dto/createPost.input"), { "CreatePostInput": { content: {}, title: {} } }]] } }; + return { "@nestjs/swagger/plugin": { "models": [[import("./posts/dto/pagenation-query.dto"), { "PaginationQueryDto": { page: { required: false, type: () => Number, default: 1, minimum: 1 }, limit: { required: false, type: () => Number, default: 10, minimum: 1 }, query: { required: false, type: () => String }, orderBy: { required: false, type: () => String }, direction: { required: false, type: () => Object, default: "asc" } } }]], "controllers": [[import("./app.controller"), { "AppController": { "getHello": { type: String }, "getErrorAuth": { type: Object }, "getHelloName": { type: String } } }], [import("./auth/auth.controller"), { "AuthController": { "signup": {}, "login": {}, "refreshToken": {}, "logout": {} } }], [import("./users/users.controller"), { "UserController": { "getProfile": { type: t["./users/dto/response-user-dto"].UserResponseDto }, "updateUser": { type: Object }, "changePassword": { type: Object } } }], [import("./posts/posts.controller"), { "PostsController": { "createPost": { type: Object }, "getPublishedPosts": {}, "getUserPosts": {}, "getPost": { type: Object } } }]] }, "@nestjs/graphql/plugin": { "models": [[import("./auth/dto/signup.input"), { "SignupInput": { email: {}, password: {}, username: { nullable: true } } }], [import("./auth/models/token.model"), { "Token": { accessToken: {}, refreshToken: {} } }], [import("./common/models/base.model"), { "BaseModel": { id: {}, createdAt: {}, updatedAt: {} } }], [import("./posts/models/post.model"), { "Post": { title: {}, content: { nullable: true }, published: {}, imgUrl: { nullable: true }, author: { nullable: true } } }], [import("./users/models/user.model"), { "User": { email: {}, username: { nullable: true }, role: {}, posts: { nullable: true } } }], [import("./auth/models/auth.model"), { "Auth": { user: { type: () => t["./users/models/user.model"].User } } }], [import("./auth/dto/login.input"), { "LoginInput": { email: {}, password: {} } }], [import("./auth/dto/refresh-token.input"), { "RefreshTokenInput": { token: {} } }], [import("./users/dto/change-password.input"), { "ChangePasswordInput": { oldPassword: {}, newPassword: {} } }], [import("./users/dto/update-user.input"), { "UpdateUserInput": { username: { nullable: true } } }], [import("./common/pagination/pagination.args"), { "PaginationArgs": { skip: { nullable: true, type: () => Number }, after: { nullable: true, type: () => String }, before: { nullable: true, type: () => String }, first: { nullable: true, type: () => Number }, last: { nullable: true, type: () => Number } } }], [import("./posts/args/post-id.args"), { "PostIdArgs": { postId: { type: () => String } } }], [import("./posts/args/user-id.args"), { "UserIdArgs": { userId: { type: () => String } } }], [import("./common/pagination/page-info.model"), { "PageInfo": { endCursor: { nullable: true }, hasNextPage: {}, hasPreviousPage: {}, startCursor: { nullable: true } } }], [import("./posts/models/post-connection.model"), { "PostConnection": {} }], [import("./posts/dto/post-order.input"), { "PostOrder": { field: {} } }], [import("./posts/dto/createPost.input"), { "CreatePostInput": { content: {}, title: {}, price: {} } }]] } }; }; \ No newline at end of file