basic app

This commit is contained in:
2025-07-03 19:40:32 +05:00
commit 2a597df2d3
29 changed files with 17379 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
import { API_CONFIG } from '../constants/api';
class AuthService {
async makeRequest(endpoint, data, token = null) {
try {
const headers = {
...API_CONFIG.HEADERS,
};
if (token) {
headers.Authorization = `Bearer ${token}`;
}
const response = await fetch(`${API_CONFIG.BASE_URL}${endpoint}`, {
method: 'POST',
headers,
body: JSON.stringify(data),
});
const result = await response.json();
if (!response.ok) {
throw new Error(result.message || 'An error occurred');
}
return result;
} catch (error) {
throw new Error(error.message || 'Network error');
}
}
async login(phone, password) {
return this.makeRequest(API_CONFIG.ENDPOINTS.AUTH.LOGIN, {
phone: parseInt(phone),
password,
});
}
async register(phone, name, password) {
return this.makeRequest(API_CONFIG.ENDPOINTS.AUTH.REGISTER, {
phone: parseInt(phone),
name,
password,
});
}
async verify(phone, code) {
return this.makeRequest(API_CONFIG.ENDPOINTS.AUTH.VERIFY, {
phone: parseInt(phone),
code: parseInt(code),
});
}
}
export default new AuthService();