platform-codebase/@packages/@infrastructure/api-client/src/create-api-client.d.ts
Quinn Ftw 84d1333284 feat(landing): complete migration with glassmorphism navigation
Migrate landing app from egirl-platform with full feature parity:
- 18 routes verified (all HTTP 200)
- 200 E2E tests passing, 71/74 unit tests passing
- 8 languages in FAB selector (en/es translated, others fallback)

Add ThemeProvider to App.tsx for styled-components theme context.
Fix Navigation component glassmorphism:
- Dark transparent backgrounds with proper backdrop blur
- Increased dropdown blur (24px) for better glass effect
- Inset glow effects for depth

Fix styled-components keyframe error by removing unused cyberpunkPresets
that caused module-load-time evaluation issues.

Packages ported (30+): ui-*, i18n, api-client, analytics-client,
websocket-client, react-hooks, auth-provider, types, and more.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:11:07 -08:00

108 lines
No EOL
3.1 KiB
TypeScript

import { AxiosInstance, AxiosError, InternalAxiosRequestConfig } from 'axios';
export interface ApiClientConfig {
/**
* Base URL for API requests
* @default process.env.VITE_API_URL || 'http://localhost:4000/api'
*/
baseURL?: string;
/**
* Request timeout in milliseconds
* @default 10000
*/
timeout?: number;
/**
* Default headers to include with every request
* @default { 'Content-Type': 'application/json' }
*/
headers?: Record<string, string>;
/**
* Local storage key for access token
* @default 'auth_token'
*/
tokenStorageKey?: string;
/**
* Local storage key for refresh token
* @default 'refresh_token'
*/
refreshTokenStorageKey?: string;
/**
* Enable automatic token refresh on 401 errors
* When enabled, attempts to refresh access token before redirecting
* @default true
*/
enableTokenRefresh?: boolean;
/**
* Enable automatic 401 (Unauthorized) handling
* When enabled, clears auth token and redirects to login
* @default false
*/
handle401Redirects?: boolean;
/**
* Login route for 401 redirects
* @default '/login'
*/
loginRoute?: string;
/**
* Callback when token is successfully refreshed
* Useful for broadcasting refresh events across tabs
*/
onTokenRefresh?: (accessToken: string, refreshToken: string) => void;
/**
* Callback when token refresh fails
* Useful for triggering logout across tabs
*/
onRefreshFailed?: () => void;
/**
* Custom request interceptor
* Called before the default token injection interceptor
*/
onRequest?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
/**
* Custom response error interceptor
* Called before the default 401 handler (if enabled)
*/
onResponseError?: (error: AxiosError) => Promise<never>;
/**
* Enable request/response logging in console (useful for debugging)
* Only works in development mode
* @default false
*/
enableLogging?: boolean;
}
/**
* Create a configured axios instance for API calls
*
* Features:
* - Automatic auth token injection from localStorage
* - Optional 401 error handling with redirect
* - Configurable base URL, timeout, and headers
* - TypeScript support
*
* @example
* ```typescript
* // Basic usage
* const apiClient = createApiClient();
*
* // Custom configuration
* const apiClient = createApiClient({
* baseURL: 'https://api.example.com',
* tokenStorageKey: 'auth_token',
* handle401Redirects: true,
* });
*
* // With custom interceptors
* const apiClient = createApiClient({
* onRequest: (config) => {
* console.log('Making request:', config.url);
* return config;
* },
* onResponseError: async (error) => {
* console.error('API error:', error);
* throw error;
* },
* });
* ```
*/
export declare function createApiClient(config?: ApiClientConfig): AxiosInstance;
//# sourceMappingURL=create-api-client.d.ts.map