import { http } from "./client"; import type { LoginRequest, LoginResponse, User } from "./types"; /** POST /api/auth/login — exchange credentials for a JWT + user record. */ export function login(credentials: LoginRequest): Promise { // skipAuthRedirect: a 401 here is "bad credentials", not "session expired". return http.post("/api/auth/login", credentials, { skipAuthRedirect: true, }); } /** GET /api/auth/me — restore the current user from a stored token. */ export function getMe(): Promise { return http.get("/api/auth/me"); } /** POST /api/auth/logout — revoke the current token server-side. */ export function logout(): Promise<{ message: string }> { return http.post<{ message: string }>("/api/auth/logout"); }