turash/bugulma/frontend/lib/api-config.ts
Damir Mukimov 28f06d5787
Some checks failed
CI/CD Pipeline / backend-lint (push) Failing after 31s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / frontend-lint (push) Failing after 1m22s
CI/CD Pipeline / frontend-build (push) Has been skipped
CI/CD Pipeline / e2e-test (push) Has been skipped
fix: resolve React Compiler and linting errors
- Fix React Compiler memoization issues in useOrganizationPage.ts
- Replace useCallback with useRef pattern in useKeyboard.ts
- Remove unnecessary dependencies from useMemo hooks
- Fix prettier formatting in api-client.ts and api-config.ts
- Replace any types with proper types in error-handling, http-client, security
- Remove unused imports and variables
- Move ImpactBreakdownChart component outside render in ImpactMetrics.tsx
- Fix setState in effect by using useMemo in HeritageBuildingPage.tsx
- Memoize getHistoryTitle with useCallback in MatchDetailPage and MatchNegotiationPage
- Add i18n for literal strings in community pages and LoginPage
- Fix missing dependencies in DashboardPage and DiscoveryPage
2025-12-25 00:21:47 +01:00

43 lines
1.3 KiB
TypeScript

/**
* Global API Configuration
* Centralizes API endpoint configuration for consistent routing across all services
*/
// API Version Configuration
export const API_CONFIG = {
VERSION: 'v1',
BASE_PATH: `/api/v1`,
} as const;
// Environment-specific API base URL
const isProduction = import.meta.env.PROD;
export const API_BASE_URL =
import.meta.env.VITE_API_BASE_URL || (isProduction ? 'https://api.bugulma.city' : '');
// Full API base URL with version
export const API_FULL_BASE_URL = `${API_BASE_URL}${API_CONFIG.BASE_PATH}`;
// Service endpoint paths (relative to API version)
export const API_ENDPOINTS = {
ORGANIZATIONS: '/organizations',
SITES: '/sites',
MATCHING: '/matching',
ANALYTICS: '/analytics',
HERITAGE: '/heritage',
AI: '/ai',
PROPOSALS: '/proposals',
AUTH: '/auth',
} as const;
// Development-time configuration validation (simplified)
if (import.meta.env.DEV) {
// Basic validation without complex Zod schemas
// In development, API_BASE_URL can be empty string (uses relative URLs)
if (typeof API_BASE_URL !== 'string') {
console.error('🚨 API_BASE_URL is not properly configured');
}
if (!API_CONFIG.VERSION || typeof API_CONFIG.VERSION !== 'string') {
console.error('🚨 API version is not properly configured');
}
}