backend sliced by modules

This commit is contained in:
2026-05-02 18:24:57 +07:00
parent b6306d5aa9
commit 693e48af59
42 changed files with 1602 additions and 779 deletions
+10 -7
View File
@@ -1,12 +1,13 @@
// Берем из .env, иначе используем дефолт
export const API_BASE = import.meta.env.VITE_API_BASE || "/api";
// Базовый путь теперь смотрит на /api/v1
export const API_BASE = import.meta.env.VITE_API_BASE || "/api/v1";
export const TOKEN_KEY = "nrxp_token";
export const fetchProfile = async () => {
const token = localStorage.getItem(TOKEN_KEY);
if (!token) throw new Error("No token found");
const res = await fetch(`${API_BASE}/me`, {
// Путь: /api/v1/users/me
const res = await fetch(`${API_BASE}/users/me`, {
headers: { Authorization: `Bearer ${token}` },
});
@@ -18,7 +19,8 @@ export const submitHackResult = async (score: number) => {
const token = localStorage.getItem(TOKEN_KEY);
if (!token) throw new Error("No token found");
const res = await fetch(`${API_BASE}/hack/result`, {
// Путь: /api/v1/users/hack/result
const res = await fetch(`${API_BASE}/users/hack/result`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -31,10 +33,10 @@ export const submitHackResult = async (score: number) => {
return res.json();
};
// 🔥 ИСПРАВЛЕНО: Правильный парсинг ошибки Триала
export const activateTrial = async () => {
const token = localStorage.getItem(TOKEN_KEY);
const res = await fetch(`${API_BASE}/trial`, {
// Путь: /api/v1/billing/trial
const res = await fetch(`${API_BASE}/billing/trial`, {
method: "POST",
headers: { Authorization: `Bearer ${token}` },
});
@@ -47,7 +49,8 @@ export const activateTrial = async () => {
export const buySubscription = async (plan: string) => {
const token = localStorage.getItem(TOKEN_KEY);
const res = await fetch(`${API_BASE}/subscribe`, {
// Путь: /api/v1/billing/subscribe
const res = await fetch(`${API_BASE}/billing/subscribe`, {
method: "POST",
headers: {
"Content-Type": "application/json",