fitaiProto/apps/mobile/src/config/api.ts

72 lines
2.0 KiB
TypeScript

// Use environment variable for API URL
// Set EXPO_PUBLIC_API_URL in your .env file
const getApiBaseUrl = (): string => {
const envUrl = process.env.EXPO_PUBLIC_API_URL;
if (envUrl) {
return envUrl;
}
// Fallback for development if not set
if (__DEV__) {
console.warn(
"EXPO_PUBLIC_API_URL not set in .env - using default localhost",
);
return "http://localhost:3000";
}
// Production MUST have URL set
throw new Error(
"EXPO_PUBLIC_API_URL must be set in production environment variables",
);
};
export const API_BASE_URL = getApiBaseUrl();
export const API_ENDPOINTS = {
AUTH: {
LOGIN: "/api/auth/login",
REGISTER: "/api/auth/register",
},
PROFILE: {
FITNESS: "/api/fitness-profile",
},
CLIENTS: "/api/clients",
USERS: {
LIST: "/api/users",
STATISTICS: "/api/users/statistics",
GYM: "/api/users/gym",
},
GYMS: "/api/gyms",
ATTENDANCE: {
CHECK_IN: "/api/attendance/check-in",
CHECK_OUT: "/api/attendance/check-out",
HISTORY: "/api/attendance/history",
},
RECOMMENDATIONS: "/api/recommendations",
MEMBERSHIP: {
FEATURES: "/api/membership/features",
},
NUTRITION: {
BASE: "/api/nutrition",
MEALS: "/api/nutrition/meals",
GET_BY_DATE: (date: string) => `/api/nutrition?date=${date}`,
GET_RANGE: (startDate: string, endDate: string) =>
`/api/nutrition?startDate=${startDate}&endDate=${endDate}`,
},
HYDRATION: {
BASE: "/api/hydration",
GET_BY_DATE: (date: string) => `/api/hydration?date=${date}`,
GET_RANGE: (startDate: string, endDate: string) =>
`/api/hydration?startDate=${startDate}&endDate=${endDate}`,
},
FITNESS_GOALS: {
LIST: "/api/fitness-goals",
CREATE: "/api/fitness-goals",
GET: (id: string) => `/api/fitness-goals/${id}`,
UPDATE: (id: string) => `/api/fitness-goals/${id}`,
DELETE: (id: string) => `/api/fitness-goals/${id}`,
COMPLETE: (id: string) => `/api/fitness-goals/${id}/complete`,
},
};