Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/axios/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import baseAxios from 'axios';

const axiosInstance = baseAxios.create({
baseURL: process.env.NEXT_PUBLIC_API_URL,
withCredentials: true,
});
export default axiosInstance;
37 changes: 37 additions & 0 deletions src/types/api.ts
Original file line number Diff line number Diff line change
@@ -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<T> {
offset: number;
limit: number;
count: number;
hasNext: boolean;
items: T[];
links: Link[];
}

export interface ApiResponse<T> {
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 };
}
Empty file removed src/types/index.ts
Empty file.
16 changes: 16 additions & 0 deletions src/types/shop.ts
Original file line number Diff line number Diff line change
@@ -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;
};
}
32 changes: 32 additions & 0 deletions src/types/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ApiResponse, AuthRequest, AuthResponse } from './api';
import { Shop } from './shop';

/* -------------------- 로그인 -------------------- */

export type LoginRequest = AuthRequest;

export type LoginResponse = ApiResponse<AuthResponse>;

/* ------------------- 회원가입 ------------------ */

export type UserRequest = AuthRequest & {
type: UserType;
};

export type UserResponse = ApiResponse<UserBase>;

/* -------------------- 유저 -------------------- */
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;
}
Loading