Merge branch 'main' into merge_branch

This commit is contained in:
magdo
2025-10-15 17:05:59 +02:00
10 changed files with 278 additions and 168 deletions
+39 -20
View File
@@ -1,12 +1,11 @@
import axios from 'axios';
import axios from "axios"
export const API_CONFIG = {
baseURL: import.meta.env.VITE_API_URL+'/api',
wsURL: 'http://localhost:3000',
baseURL: import.meta.env.VITE_API_URL + "/api",
wsURL: "http://localhost:3000",
timeout: 10000,
retryAttempts: 3
};
retryAttempts: 3,
}
export const apiClient = axios.create({
baseURL: API_CONFIG.baseURL,
@@ -19,20 +18,40 @@ export const apiClient = axios.create({
//login
export const login = async (username, password) => {
try {
const response = await apiClient.post('/users/login', { username, password });
return response.data;
} catch (error) {
throw error;
}
};
try {
const response = await apiClient.post("/users/login", { username, password })
return response.data
} catch (error) {
throw error
}
}
//register
export const register = async (username, email, password, fname, lname, phone) => {
try {
const response = await apiClient.post('/users/create', { username, email, password, fname, lname, phone });
return response.data;
} catch (error) {
throw error;
}
};
try {
const response = await apiClient.post("/users/create", { username, email, password, fname, lname, phone })
return { ...response.data, status: response.status }
} catch (error) {
throw error
}
}
//verify email
export const verifyEmail = async (token) => {
try {
const response = await apiClient.get(`/users/verify-email/${token}`)
return response.data
} catch (error) {
throw error
}
}
// Get current user's game statistics
export const getUserStats = async () => {
try {
const response = await apiClient.get("/users/me/stats")
return response.data
} catch (error) {
throw error
}
}