| import apiClient from './apiClient'; | |
| export interface LoginCredentials { | |
| email: string; | |
| password: string; | |
| } | |
| export interface SignupCredentials { | |
| email: string; | |
| password: string; | |
| name: string; | |
| } | |
| export interface AuthResponse { | |
| user: { | |
| id: string; | |
| email: string; | |
| name: string; | |
| }; | |
| token: string; | |
| } | |
| export const authApi = { | |
| login: async (credentials: LoginCredentials): Promise<AuthResponse> => { | |
| const response = await apiClient.post<AuthResponse>('/auth/login', credentials); | |
| return response.data; | |
| }, | |
| signup: async (credentials: SignupCredentials): Promise<AuthResponse> => { | |
| const response = await apiClient.post<AuthResponse>('/auth/signup', credentials); | |
| return response.data; | |
| }, | |
| logout: async (): Promise<void> => { | |
| await apiClient.post('/auth/logout'); | |
| localStorage.removeItem('authToken'); | |
| }, | |
| getCurrentUser: async (): Promise<AuthResponse['user']> => { | |
| const response = await apiClient.get<AuthResponse['user']>('/auth/me'); | |
| return response.data; | |
| } | |
| }; | |