import { getRequest, postRequest } from '.'; import { RegisterUser, ResponseAuth } from './auth.types'; export async function login(email: string, password: string): Promise { const response = await postRequest('auth/login', { email, password }); if (response?.status === 200) { return response.data as ResponseAuth; } else { return undefined; } } export async function register(user: RegisterUser): Promise { const response = await postRequest('auth/register', user); if (response?.status === 201) { return true; } else { return false; } } export async function logout() { return await postRequest('auth/logout', {}); } export async function refresh(refresh_token_rotation?: boolean): Promise { const response = await getRequest('auth/refresh', { params: { refresh_token_rotation } }); if (response?.status === 200) { return response.data as ResponseAuth; } else { return undefined; } } export async function me(): Promise { const response = await getRequest('auth/me'); if (response?.status === 200) { return response.data; } else { return undefined; } }