Files
forkmessager/apps/web/src/modules/auth/infrastructure/authApi.ts
Халимов Рустам fb252f9d87 pre-deep-ddd-refactor
2026-03-19 22:07:23 +03:00

31 lines
883 B
TypeScript

import { httpClient } from '../../../lib/httpClient';
import type { User } from '../../../lib/types';
export class AuthApi {
static async login(username: string, password: string) {
return httpClient.request<{ token: string; user: User }>('/auth/login', {
method: 'POST',
body: JSON.stringify({ username, password }),
});
}
static async register(username: string, displayName: string, password: string, bio?: string) {
return httpClient.request<{ token: string; user: User }>('/auth/register', {
method: 'POST',
body: JSON.stringify({ username, displayName, password, bio }),
});
}
static async getMe() {
return httpClient.request<{ user: User }>('/auth/me');
}
static async getConfig() {
return httpClient.request<any>('/config');
}
static setToken(token: string | null) {
httpClient.setToken(token);
}
}