Skip to content
Merged
2 changes: 1 addition & 1 deletion src/app/(pages)/sign-in/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { SubmitHandler, useForm } from 'react-hook-form'

import { SignInRequest } from '@/types/api/auth.types'
import { SignInRequest } from '@/types/api/Auth.types'
import { useSignInMutation } from 'queries/useSignIn'

export default function LoginPage(): JSX.Element {
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/sign-up/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// import { useRouter } from 'next/navigation'
import { SubmitHandler, useForm } from 'react-hook-form'

import { SignUpRequest } from '@/types/api/auth.types'
import { SignUpRequest } from '@/types/api/Auth.types'
import { useSignUpMutation } from 'queries/useSignUp'

export default function SignUpPage(): JSX.Element {
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/auth/sign-in/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextResponse } from 'next/server'

import { SignInRequest, SignInResponse } from '@/types/api/auth.types'
import { SignInRequest, SignInResponse } from '@/types/api/Auth.types'
import { HTTPError } from 'ky'

import { backendApi } from '@/services/api'
Expand Down
2 changes: 1 addition & 1 deletion src/services/auth/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SignInRequest, SignUpRequest } from '@/types/api/auth.types'
import { SignInRequest, SignUpRequest } from '@/types/api/Auth.types'

import { backendApi, proxyApi } from '@/services/api'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ export interface paths {
patch?: never
trace?: never
}
'/v1/my-page/check-nickname': {
parameters: {
query?: never
header?: never
path?: never
cookie?: never
}
get?: never
put?: never
/** 닉네임 중복 체크 */
post: operations['checkNicknameDuplicate']
delete?: never
options?: never
head?: never
patch?: never
trace?: never
}
Comment on lines +61 to +76
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'never' 타입을 적용하는 건 처음 보네요! 찾아보니
의 용도로 사용한다고 하는군요.. 덕분에 never 타입에 대해 알아갑니다!
그러면 타입 스크립트에서 타입 지정이 필요없을 때 ? 사용하는 것 같은데,
정확히 어떤 목적으로 사용되는 건지 알려주실 수 있나요 ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApiSchema.types.d.ts 파일 같은 경우 제가 openapi-typescript 라는 도구를 사용하여 민지님이 작업해주신 스펙에 있는 타입을 그대로 타입스크립트 파일로 생성한 결과물입니다 !

my-page-check-nickname 엔드포인트에서는 post 메서드만 있고 나머지의 경우는 없고, 다른 요구하는 쿼리 등이 없어서 never 로 타입이 변환된 듯 하네요.
http://43.202.50.174:8080/v3/api-docs 실제 스펙에서는 never 로 지정되어 있지 않지만, 특정 엔드포인트에서 존재하지 않는 요청에 대해서 타입스크립트로 변환할 때 never 타입으로 자동 생성된 듯 합니다 !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 ㅎㅎ 민지님께서 작업해주신 것을 바탕으로 타입을 생성해주셔서 그런 거군요! 감사합니다 ~

'/v1/likes': {
parameters: {
query?: never
Expand Down Expand Up @@ -797,12 +814,6 @@ export interface components {
* "태그4"
* ] */
tags: string[]
/**
* @description 포트폴리오 이미지 url
* @default default_image_url
* @example 이미지url
*/
portImageUrl: string
/** @description 포트폴리오 링크 리스트 */
links?: components['schemas']['LinkRequest'][]
/** @description 포트폴리오 학력 리스트 */
Expand Down Expand Up @@ -1062,6 +1073,19 @@ export interface components {
/** @description 경력 리스트 */
careers?: components['schemas']['CareerResponse'][]
}
checkNicknameRequest: {
/**
* @description 회원 닉네임
* @example new_nickname
*/
nickname: string
}
ApiResponseBoolean: {
isSuccess?: boolean
code?: string
message?: string
result?: boolean
}
LikeRequest: {
/**
* Format: int64
Expand Down Expand Up @@ -1293,12 +1317,6 @@ export interface components {
*/
email: string
}
ApiResponseBoolean: {
isSuccess?: boolean
code?: string
message?: string
result?: boolean
}
ApiResponseString: {
isSuccess?: boolean
code?: string
Expand All @@ -1317,11 +1335,6 @@ export interface components {
* @example 뽀꼬
*/
nickname?: string
/**
* @description 프로필 사진 url
* @example aaa.com
*/
imageUrl?: string
/**
* @description 소개문구
* @example 간단한 소개글을 작성해보세요!
Expand Down Expand Up @@ -2131,6 +2144,34 @@ export interface operations {
}
}
createPortfolio: {
parameters: {
query?: never
header?: never
path?: never
cookie?: never
}
requestBody?: {
content: {
'multipart/form-data': {
request: components['schemas']['PortfolioCreateRequest']
/** Format: binary */
portImage?: string
}
}
}
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown
}
content: {
'application/json': components['schemas']['ApiResponsePortCreateResponse']
}
}
}
}
checkNicknameDuplicate: {
parameters: {
query?: never
header?: never
Expand All @@ -2139,7 +2180,7 @@ export interface operations {
}
requestBody: {
content: {
'application/json': components['schemas']['PortfolioCreateRequest']
'application/json': components['schemas']['checkNicknameRequest']
}
}
responses: {
Expand All @@ -2149,7 +2190,7 @@ export interface operations {
[name: string]: unknown
}
content: {
'*/*': components['schemas']['ApiResponsePortCreateResponse']
'*/*': components['schemas']['ApiResponseBoolean']
}
}
}
Expand Down Expand Up @@ -2457,9 +2498,13 @@ export interface operations {
path?: never
cookie?: never
}
requestBody: {
requestBody?: {
content: {
'application/json': components['schemas']['ProfileUpdateRequest']
'multipart/form-data': {
request: components['schemas']['ProfileUpdateRequest']
/** Format: binary */
profileImage?: string
}
}
}
responses: {
Expand All @@ -2469,7 +2514,7 @@ export interface operations {
[name: string]: unknown
}
content: {
'*/*': components['schemas']['ApiResponseProfileUpdateResponse']
'application/json': components['schemas']['ApiResponseProfileUpdateResponse']
}
}
}
Expand All @@ -2483,7 +2528,7 @@ export interface operations {
}
requestBody: {
content: {
'application/json': components['schemas']['PasswordUpdateRequest']
'multipart/form-data': components['schemas']['PasswordUpdateRequest']
}
}
responses: {
Expand Down
17 changes: 0 additions & 17 deletions src/types/api/auth.types.d.ts → src/types/api/Auth.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,3 @@ export interface CheckEmailRequest {
email: Email // 검사하고자 하는 이메일
}
export type CheckEmailResponse = boolean

/*
path: '/v1/my-page/password'
PATCH: 마이 페이지 비밀번호 수정
*/
export interface PasswordUpdateRequest {
password: Password // 새 비밀번호
}

/*
PasswordUpdateResponse
{
"isSuccess": true,
"code": "COMMON200",
"message": "비밀번호 수정이 완료되었습니다."
}
*/
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ interface User {

// MemberInfo: 일부 사용자 정보를 제외한 타입
type MemberInfo = Omit<User, 'email' | 'name'>

interface MultipartFormData<T> {
request: T
/** Format: binary */
file?: File
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,44 @@ export interface GetProfileResponse extends ProfileBase, User {
/*
PATCH: 마이페이지 프로필 저장
*/
export type ProfileUpdateRequest = ProfileBase
export type ProfileUpdateRequest = MultipartFormData<ProfileBase>

export interface ProfileUpdateResponse extends ProfileBase {
completionRate?: number // 포트폴리오 완성률 (%)
}

/*
path: '/v1/my-page/check-nickname'
POST: 닉네임 중복 체크
*/
export interface CheckNicknameRequest {
nickname: Nickname // 닉네임 중복 검사 대상
}

export type CheckNicknameResponse = boolean

/*
PasswordUpdateResponse
{
"isSuccess": true,
"code": "COMMON200",
"message": "비밀번호 수정이 완료되었습니다."
}
*/

/*
path: '/v1/my-page/password'
PATCH: 마이 페이지 비밀번호 수정
*/
export interface PasswordUpdateRequest {
password: Password // 새 비밀번호
}

/*
PasswordUpdateResponse
{
"isSuccess": true,
"code": "COMMON200",
"message": "비밀번호 수정이 완료되었습니다."
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export interface LanguageAwardRequest extends AwardRequestBase, LanguageAward {
// 포트폴리오 리스트 조회
export type PortfolioListItem = PortfolioBase & PostBaseBody

// 포트폴리오 생성 요청 타입
export interface PortfolioCreateRequest extends PortfolioBase {
// 포트폴리오 리스트 조회
export interface PortfolioDetail extends PortfolioBase {
portContent: string // 상세 내용
techStacks: TechStack[] // 사용 기술 스택
links?: PortfolioLink[] // 외부 링크
Comment on lines +99 to 103
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전부터 느꼈지만, 여러 번 재사용되는 타입을 기본 base 타입을 지정해두고, extends 하니 여러번 정의해줘야하는 번거로움을 피할 수 있어서 정말 좋네요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 맞아요 !

Expand All @@ -111,5 +111,8 @@ export interface PortfolioCreateRequest extends PortfolioBase {
careers?: PortfolioCareer[] // 경력 리스트
}

// 포트폴리오 생성 요청 타입
export type PortfolioCreateRequest = MultipartFormData<PortfolioDetail>

// 포트폴리오 생성 응답 타입
export type PortfolioCreateResponse = PortfolioCreateRequest & PostBaseBody
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading