diff --git a/src/lib/axios/index.ts b/src/lib/axios/index.ts index 68af766..9b2b298 100644 --- a/src/lib/axios/index.ts +++ b/src/lib/axios/index.ts @@ -2,5 +2,6 @@ import baseAxios from 'axios'; const axiosInstance = baseAxios.create({ baseURL: process.env.NEXT_PUBLIC_API_URL, + withCredentials: true, }); export default axiosInstance; diff --git a/src/types/api.ts b/src/types/api.ts new file mode 100644 index 0000000..99805b7 --- /dev/null +++ b/src/types/api.ts @@ -0,0 +1,37 @@ +import { User } from './user'; + +/* -------------------- 공통 타입 -------------------- */ +export interface Link { + rel: string; + description: string; + method: 'GET' | 'POST' | 'PUT' | 'DELETE'; + href: string; +} + +export interface PaginatedResponse { + offset: number; + limit: number; + count: number; + hasNext: boolean; + items: T[]; + links: Link[]; +} + +export interface ApiResponse { + item: T; + links: Link[]; +} + +export interface ApiError { + message: string; +} + +export interface AuthRequest { + email: string; + password: string; +} + +export interface AuthResponse { + token: string; + user: { item: User; href: string }; +} diff --git a/src/types/index.ts b/src/types/index.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/types/shop.ts b/src/types/shop.ts new file mode 100644 index 0000000..5e340cb --- /dev/null +++ b/src/types/shop.ts @@ -0,0 +1,16 @@ +import { User } from './user'; + +export interface Shop { + id: string; + name: string; + category: string; + address1: string; + address2: string; + description: string; + imageUrl: string; + originalHourlyPay: number; + user?: { + item: User; + href?: string; + }; +} diff --git a/src/types/user.ts b/src/types/user.ts new file mode 100644 index 0000000..6e1dfc7 --- /dev/null +++ b/src/types/user.ts @@ -0,0 +1,32 @@ +import { ApiResponse, AuthRequest, AuthResponse } from './api'; +import { Shop } from './shop'; + +/* -------------------- 로그인 -------------------- */ + +export type LoginRequest = AuthRequest; + +export type LoginResponse = ApiResponse; + +/* ------------------- 회원가입 ------------------ */ + +export type UserRequest = AuthRequest & { + type: UserType; +}; + +export type UserResponse = ApiResponse; + +/* -------------------- 유저 -------------------- */ +export type UserType = 'employer' | 'employee'; + +export interface UserBase { + id: string; + email: string; + type: UserType; +} +export interface User extends UserBase { + name?: string; + phone?: string; + address?: string; + bio?: string; + shop?: { item: Shop } | null; +}