satupeta-main/shared/services/auth.ts

30 lines
544 B
TypeScript
Raw Normal View History

2026-01-27 02:31:12 +00:00
import { User } from "../types/user";
import { apiHelpers } from "./api";
interface LoginPayload {
email: string;
password: string;
}
interface LoginResponse {
token: string;
user: User;
}
const authApi = {
login: async (credentials: LoginPayload): Promise<LoginResponse> => {
return apiHelpers.post("/auth/login", credentials);
},
logout: async (): Promise<void> => {
return apiHelpers.post("/auth/logout");
},
me: async (): Promise<User> => {
return apiHelpers.get("/me");
},
};
export default authApi;