/** * Ziya Application Configuration * Centralized configuration for all app settings */ export interface AppConfig { app: { name: string; version: string; description: string; author: string; }; development: { nuxt: { host: string; port: number; https: boolean; }; electron: { devTools: boolean; reloadOnChange: boolean; }; }; production: { electron: { devTools: boolean; }; }; window: { minHeight: number; minWidth: number; maxHeight: number; maxWidth: number; defaultHeight: number; defaultWidth: number; titleBarStyle: 'default' | 'hidden' | 'hiddenInset' | 'customButtonsOnHover'; }; theme: { defaultPalette: number; defaultDarkMode: boolean; availablePalettes: number[]; }; redis: { host: string; port: number; db: number; keyPrefix: string; }; security: { csp: { scriptSrc: string[]; styleSrc: string[]; imgSrc: string[]; }; }; } /** * Default configuration */ export const appConfig: AppConfig = { app: { name: 'Ziya', version: '1.0.0', description: 'One stop shop trading solution', author: 'bismillahDAO', }, development: { nuxt: { host: 'localhost', port: 3000, https: false, }, electron: { devTools: true, reloadOnChange: true, }, }, production: { electron: { devTools: false, }, }, window: { minHeight: 800, minWidth: 1080, maxHeight: 1080, maxWidth: 1920, defaultHeight: 1024, defaultWidth: 1280, titleBarStyle: 'hidden', }, theme: { defaultPalette: 1, defaultDarkMode: false, availablePalettes: Array.from({ length: 24 }, (_, i) => i + 1), }, redis: { host: 'localhost', port: 6379, db: 0, keyPrefix: 'ziya:', }, security: { csp: { scriptSrc: ["'self'", "'unsafe-inline'"], styleSrc: ["'self'", "'unsafe-inline'"], imgSrc: ["'self'", 'data:', 'https:'], }, }, }; /** * Get configuration value with environment override support */ export function getConfig(): AppConfig { // Allow environment variables to override config const config = { ...appConfig }; // Override with environment variables if they exist if (process.env.NUXT_DEV_PORT) { config.development.nuxt.port = parseInt(process.env.NUXT_DEV_PORT, 10); } if (process.env.NUXT_DEV_HOST) { config.development.nuxt.host = process.env.NUXT_DEV_HOST; } if (process.env.REDIS_HOST) { config.redis.host = process.env.REDIS_HOST; } if (process.env.REDIS_PORT) { config.redis.port = parseInt(process.env.REDIS_PORT, 10); } return config; } /** * Get the development server URL */ export function getDevServerUrl(): string { const config = getConfig(); const { host, port, https } = config.development.nuxt; const protocol = https ? 'https' : 'http'; return `${protocol}://${host}:${port}`; } /** * Environment-specific configuration helpers */ export const isDevelopment = process.env.NODE_ENV === 'development'; export const isProduction = process.env.NODE_ENV === 'production'; export const isElectron = process.env.IS_ELECTRON === 'true'; export default appConfig;