This commit is contained in:
2026-08-11 21:09:32 +07:00
parent e63c8f61aa
commit 94c0c47fd0
44 changed files with 5215 additions and 71 deletions
+40
View File
@@ -0,0 +1,40 @@
import client from '@/api/client';
import type { ApiListResponse, ApiResponse } from '@/types/api';
import type { AuthUser, LoginCredentials, LoginResponse, RefreshResponse } from '../types';
/**
* Endpoint constants live here (not scattered in components).
* Contract per backend `aplp.backend.spring` (candidate, confirm at Phase 0).
*/
const ENDPOINTS = {
login: '/auth/login',
logout: '/auth/logout',
refresh: '/auth/refresh',
me: '/auth/me',
} as const;
export const authApi = {
async login(credentials: LoginCredentials): Promise<LoginResponse> {
const { data } = await client.post<ApiResponse<LoginResponse>>(ENDPOINTS.login, credentials);
return data.data;
},
async logout(): Promise<void> {
await client.post(ENDPOINTS.logout);
},
async refresh(): Promise<RefreshResponse> {
const { data } = await client.post<ApiResponse<RefreshResponse>>(ENDPOINTS.refresh);
return data.data;
},
async getMe(): Promise<AuthUser> {
const { data } = await client.get<ApiResponse<AuthUser>>(ENDPOINTS.me);
return data.data;
},
async listUsers(): Promise<ApiListResponse<AuthUser>> {
const { data } = await client.get<ApiListResponse<AuthUser>>('/users');
return data;
},
};