pre-deep-ddd-refactor
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user