react-openapi and react-auth cleanup. index.ts for react-openapi

This commit is contained in:
2026-04-04 18:01:22 +05:30
parent 86e5bc6429
commit ffa41825dd
15 changed files with 26 additions and 1733 deletions

View File

@@ -1,32 +0,0 @@
import { createApiClient } from "./axios";
import { tokenStore } from "./token";
// @ts-ignore
const authApi = createApiClient(import.meta.env.VITE_AUTH_BASE_URL);
export const authClient = {
async login(username: string, password: string) {
const res = await authApi.post("/login", { username, password });
const { access_token } = res.data;
if (!access_token) {
throw new Error("No access token returned");
}
tokenStore.set(access_token);
return this.getIdentity();
},
logout() {
tokenStore.clear();
},
async getIdentity() {
const res = await authApi.get("/me");
return res.data;
},
isAuthenticated() {
return !!tokenStore.get();
},
};

View File