pre-deep-ddd-refactor

This commit is contained in:
Халимов Рустам
2026-03-19 22:07:23 +03:00
parent abd94d6154
commit fb252f9d87
34 changed files with 1152 additions and 975 deletions

View File

@@ -0,0 +1,59 @@
import { httpClient } from '../../../lib/httpClient';
import type { User, UserPresence } from '../../../lib/types';
export class UserApi {
static async searchUsers(query: string) {
return httpClient.request<UserPresence[]>(`/users/search?q=${encodeURIComponent(query)}`);
}
static async getUser(id: string) {
return httpClient.request<User>(`/users/${id}`);
}
static async updateProfile(data: { displayName?: string; bio?: string; birthday?: string }) {
return httpClient.request<User>('/users/profile', {
method: 'PUT',
body: JSON.stringify(data),
});
}
static async updateSettings(settings: any) {
return httpClient.request('/users/settings', {
method: 'PUT',
body: JSON.stringify(settings),
});
}
static async uploadAvatar(file: File) {
const formData = new FormData();
formData.append('avatar', file);
return httpClient.request<User>('/users/avatar', {
method: 'POST',
body: formData,
timeout: 120_000,
});
}
static async cropAvatar(file: File, cropData: { x: number; y: number; width: number; height: number }) {
const formData = new FormData();
formData.append('avatar', file);
formData.append('cropX', cropData.x.toString());
formData.append('cropY', cropData.y.toString());
formData.append('cropWidth', cropData.width.toString());
formData.append('cropHeight', cropData.height.toString());
return httpClient.request<User>('/users/avatar/crop', {
method: 'POST',
body: formData,
timeout: 120_000,
});
}
static async removeAvatar() {
return httpClient.request<User>('/users/avatar', { method: 'DELETE' });
}
static async getIceServers() {
return httpClient.request<{ iceServers: RTCIceServer[] }>('/webrtc/ice-servers');
}
}

File diff suppressed because it is too large Load Diff