Skip to content

Commit

Permalink
fix: response.status.js 및 swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
cchoiGeon committed Aug 13, 2024
1 parent 83b8a26 commit cf80865
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions src/config/response.status.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ export const status = {
PARAMETER_IS_WRONG : {status : StatusCodes.PARAMETER_IS_WRONG, "isSuccess" : false, "code": "COMMON006", "message":"잘못된 파라미터가 전달되었습니다."},

// signup err
USERID_ALREADY_EXIST: { status: StatusCodes.CONFLICT, isSuccess: false, code: "401", message: "이미 존재하는 아이디입니다." },
EMPTY_DATA: { status: StatusCodes.CONFLICT, isSuccess: false, code: "402", message: "데이터가 비어있습니다." },
SIGNUP_ERROR: { status: StatusCodes.CONFLICT, isSuccess: false, code: "403", message: "회원가입 에러" }, // 디테일하게 수정할 필요있음
USERID_ALREADY_EXIST: { status: StatusCodes.UNAUTHORIZED, isSuccess: false, code: "SIGNUP001", message: "이미 존재하는 아이디입니다." },
SIGNUP_EMPTY_DATA: { status: StatusCodes.PAYMENT_REQUIRED, isSuccess: false, code: "SIGNUP002", message: "데이터가 비어있습니다." },
SIGNUP_ERROR: { status: StatusCodes.FORBIDDEN,isSuccess: false, code: "SIGNUP003", message: "회원가입 에러" },

// login err
USER_NOT_FOUND: { status: StatusCodes.CONFLICT, isSuccess: false, code: "401", message: "존재하지 않는 아이디입니다." },
PASSWORD_MISMATCH: { status: StatusCodes.CONFLICT, isSuccess: false, code: "403", message: "비밀번호가 일치하지 않습니다." },
USER_NOT_FOUND: { status: StatusCodes.UNAUTHORIZED, isSuccess: false, code: "LOGIN001", message: "존재하지 않는 아이디입니다." },
LOGIN_EMPTY_DATA: { status: StatusCodes.PAYMENT_REQUIRED, isSuccess: false, code: "SIGNUP002", message: "데이터가 비어있습니다." },
PASSWORD_MISMATCH: { status: StatusCodes.FORBIDDEN, isSuccess: false, code: "LOGIN002", message: "비밀번호가 일치하지 않습니다." },

// login middlewares err
TOKEN_NOT_PROVIDED: { status: StatusCodes.UNAUTHORIZED, isSuccess: false, code: "401", message: "로그인이 필요합니다." },
TOKEN_EXPIRED: { status: StatusCodes.UNAUTHORIZED, isSuccess: false, code: "403", message: "토큰을 재발급 받아주세요." },
INVALID_TOKEN: { status: StatusCodes.UNAUTHORIZED, isSuccess: false, code: "403", message: "유효하지 않은 토큰입니다." },
TOKEN_NOT_PROVIDED: { status: StatusCodes.UNAUTHORIZED, isSuccess: false, code: "LOGINMIDDLEWARES001", message: "로그인이 필요합니다." },
TOKEN_EXPIRED: { status: StatusCodes.PAYMENT_REQUIRED, isSuccess: false, code: "LOGINMIDDLEWARES002", message: "토큰을 재발급 받아주세요." },
INVALID_TOKEN: { status: StatusCodes.FORBIDDEN, isSuccess: false, code: "LOGINMIDDLEWARES003", message: "유효하지 않은 토큰입니다." },

// refreshToken err
REFRESH_TOKEN_NOT_PROVIDED: { status: StatusCodes.UNAUTHORIZED, isSuccess: false, code: "401", message: "refresh 토큰이 제공되지 않았습니다." },
REFRESH_TOKEN_INVALID: { status: StatusCodes.UNAUTHORIZED, isSuccess: false, code: "402", message: "유효하지 않은 refresh 토큰입니다." },
REFRESH_TOKEN_NOT_PROVIDED: { status: StatusCodes.UNAUTHORIZED, isSuccess: false, code: "REFRESHTOKEN001", message: "refresh 토큰이 제공되지 않았습니다." },
REFRESH_TOKEN_INVALID: { status: StatusCodes.PAYMENT_REQUIRED, isSuccess: false, code: "REFRESHTOKEN002", message: "유효하지 않은 refresh 토큰입니다." },
};
2 changes: 1 addition & 1 deletion src/domains/login/login.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function LoginLogic(req, res) {
const { user_id, password } = req.body;

if (!user_id || !password) {
return res.send(response(status.EMPTY_DATA));
return res.send(response(status.LOGIN_EMPTY_DATA));
}

const LoginData = LoginDTO(user_id, password);
Expand Down
2 changes: 1 addition & 1 deletion src/domains/signup/signup.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function SignupLogic(req, res) {
const { email, user_id, password } = req.body;

if (!email || !user_id || !password) {
return res.send(response(status.EMPTY_DATA));
return res.send(response(status.SIGNUP_EMPTY_DATA));
}

const signupData = createSignupDTO(user_id, password, email);
Expand Down
14 changes: 7 additions & 7 deletions src/swagger/login.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ paths:
type: boolean
example: true
code:
type: string
example: 2000
type: number
example: 200
message:
type: string
example: "success!"
Expand All @@ -47,7 +47,7 @@ paths:
example: false
code:
type: string
example: 400
example: COMMON001
message:
type: string
example: 잘못된 요청입니다
Expand All @@ -61,7 +61,7 @@ paths:
example: false
code:
type: string
example: 401
example: LOGIN001
message:
type: string
example: 존재하지 않는 아이디입니다.
Expand All @@ -75,7 +75,7 @@ paths:
example: false
code:
type: string
example: 402
example: LOGIN002
message:
type: string
example: 데이터가 비어있습니다.
Expand All @@ -89,7 +89,7 @@ paths:
example: false
code:
type: string
example: 403
example: LOGIN003
message:
type: string
example: 비밀번호가 일치하지 않습니다.
Expand All @@ -103,7 +103,7 @@ paths:
example: false
code:
type: string
example: 500
example: COMMON000
message:
type: string
example: 서버 에러, 관리자에게 문의 바랍니다.
8 changes: 4 additions & 4 deletions src/swagger/refreshToken.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ paths:
example: false
code:
type: string
example: 400
example: COMMON001
message:
type: string
example: 잘못된 요청입니다
Expand All @@ -43,7 +43,7 @@ paths:
example: false
code:
type: string
example: 401
example: REFRESHTOKEN001
message:
type: string
example: refresh 토큰이 존재하지 않았습니다.
Expand All @@ -57,7 +57,7 @@ paths:
example: false
code:
type: string
example: 402
example: REFRESHTOKEN002
message:
type: string
example: 유효하지 않은 refresh 토큰입니다.
Expand All @@ -71,7 +71,7 @@ paths:
example: false
code:
type: string
example: 500
example: COMMON000
message:
type: string
example: 서버 에러, 관리자에게 문의 바랍니다.
14 changes: 7 additions & 7 deletions src/swagger/signup.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ paths:
type: boolean
example: true
code:
type: string
example: 2000
type: number
example: 200
message:
type: string
example: "success!"
Expand All @@ -53,7 +53,7 @@ paths:
example: false
code:
type: string
example: 400
example: COMMON001
message:
type: string
example: 잘못된 요청입니다
Expand All @@ -67,7 +67,7 @@ paths:
example: false
code:
type: string
example: 401
example: SIGNUP001
message:
type: string
example: 이미 존재하는 아이디입니다.
Expand All @@ -81,7 +81,7 @@ paths:
example: false
code:
type: string
example: 402
example: SIGNUP002
message:
type: string
example: 데이터가 비어있습니다.
Expand All @@ -95,7 +95,7 @@ paths:
example: false
code:
type: string
example: 403
example: SIGNUP003
message:
type: string
example: 회원가입 중 오류
Expand All @@ -109,7 +109,7 @@ paths:
example: false
code:
type: string
example: 500
example: COMMON000
message:
type: string
example: 서버 에러, 관리자에게 문의 바랍니다.

0 comments on commit cf80865

Please sign in to comment.