/** * Application Configuration * * This file contains all configuration settings for the frontend application. * Centralized configuration makes it easier to manage environment-specific settings. */ // ============================================================================= // Environment Configuration // ============================================================================= /** * Set to true to use mock data instead of real backend calls. * Useful for development and testing without a running backend. */ export const NO_BACKEND_MODE = false; /** * Enable debug logging for API calls */ export const DEBUG_MODE = true; // ============================================================================= // API Configuration // ============================================================================= /** * Base URL for the backend API server */ export const API_BASE_URL = 'http://localhost:8000'; /** * API request timeout in milliseconds */ export const API_TIMEOUT = 30000; /** * API Endpoints * All backend API routes are defined here for easy reference and maintenance. */ export const API_ENDPOINTS = { // Authentication AUTH: { LOGIN: '/login', REGISTER: '/register', }, // Assets Management ASSETS: { GET: '/assets/get', CREATE: '/assets/create', CLAIM: '/assets/claim', ASSIGN: '/assets/assign', }, // AI Services AI: { PROXY: '/ai/proxy', }, // Admin Operations ADMIN: { DECLARE_GUALE: '/admin/declare-guale', }, } as const; // ============================================================================= // Helper Functions // ============================================================================= /** * Build full API URL from endpoint * @param endpoint - API endpoint path (e.g., '/login') * @returns Full URL (e.g., 'http://192.168.56.103:8000/login') */ export function buildApiUrl(endpoint: string): string { return `${API_BASE_URL}${endpoint}`; } /** * Get default headers for API requests * @param token - Optional JWT token for authenticated requests * @returns Headers object */ export function getApiHeaders(token?: string): Record { const headers: Record = { 'Content-Type': 'application/json', }; if (token) { headers['Authorization'] = `Bearer ${token}`; } return headers; } /** * Log API debug information * Only logs when DEBUG_MODE is enabled */ export function logApiDebug(label: string, data: unknown): void { if (DEBUG_MODE) { console.log(`[API Debug] ${label}:`, data); } } // ============================================================================= // Mock User Configuration (for NO_BACKEND_MODE) // ============================================================================= export const MOCK_CONFIG = { USER: { id: 999, username: 'MockCaptain', public_key: 'mock_public_key', is_admin: true, guale: false, tier: 'premium', tier_expires_at: '2026-12-31T23:59:59Z', last_active_at: new Date().toISOString(), }, ACCESS_TOKEN: 'mock_access_token', RESPONSE_DELAY: 200, // milliseconds } as const; // ============================================================================= // AI Service Configuration // ============================================================================= export const AI_CONFIG = { /** * Default system prompt for AI conversations */ DEFAULT_SYSTEM_PROMPT: 'You are a helpful journal assistant. Help the user reflect on their thoughts and feelings.', /** * Mock response delay in milliseconds (for NO_BACKEND_MODE) */ MOCK_RESPONSE_DELAY: 500, } as const; // ============================================================================= // Export Type Definitions // ============================================================================= export type ApiEndpoint = typeof API_ENDPOINTS;