/** * Admin interfaces configuration using Yup * PgAdmin, Mongo Express, Redis Insight for database management */ import { cleanEnv, envValidators } from './env-utils'; const { str, port, bool, strWithChoices } = envValidators; /** * PgAdmin configuration with validation and defaults */ export const pgAdminConfig = cleanEnv(process.env, { // PgAdmin Server PGADMIN_HOST: str('localhost', 'PgAdmin host'), PGADMIN_PORT: port(8080, 'PgAdmin port'), // Authentication PGADMIN_DEFAULT_EMAIL: str('admin@tradingbot.local', 'PgAdmin default admin email'), PGADMIN_DEFAULT_PASSWORD: str('admin123', 'PgAdmin default admin password'), // Configuration PGADMIN_SERVER_MODE: bool(false, 'Enable server mode (multi-user)'), PGADMIN_DISABLE_POSTFIX: bool(true, 'Disable postfix for email'), PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION: bool(true, 'Enhanced cookie protection'), // Security PGADMIN_MASTER_PASSWORD_REQUIRED: bool(false, 'Require master password'), PGADMIN_SESSION_TIMEOUT: str('60', 'Session timeout in minutes'), }); /** * Mongo Express configuration with validation and defaults */ export const mongoExpressConfig = cleanEnv(process.env, { // Mongo Express Server MONGO_EXPRESS_HOST: str('localhost', 'Mongo Express host'), MONGO_EXPRESS_PORT: port(8081, 'Mongo Express port'), // MongoDB Connection MONGO_EXPRESS_MONGODB_SERVER: str('mongodb', 'MongoDB server name/host'), MONGO_EXPRESS_MONGODB_PORT: port(27017, 'MongoDB port'), MONGO_EXPRESS_MONGODB_ADMINUSERNAME: str('trading_admin', 'MongoDB admin username'), MONGO_EXPRESS_MONGODB_ADMINPASSWORD: str('', 'MongoDB admin password'), // Basic Authentication for Mongo Express MONGO_EXPRESS_BASICAUTH_USERNAME: str('admin', 'Basic auth username for Mongo Express'), MONGO_EXPRESS_BASICAUTH_PASSWORD: str('admin123', 'Basic auth password for Mongo Express'), // Configuration MONGO_EXPRESS_ENABLE_ADMIN: bool(true, 'Enable admin features'), MONGO_EXPRESS_OPTIONS_EDITOR_THEME: str('rubyblue', 'Editor theme (rubyblue, 3024-night, etc.)'), MONGO_EXPRESS_REQUEST_SIZE: str('100kb', 'Maximum request size'), }); /** * Redis Insight configuration with validation and defaults */ export const redisInsightConfig = cleanEnv(process.env, { // Redis Insight Server REDIS_INSIGHT_HOST: str('localhost', 'Redis Insight host'), REDIS_INSIGHT_PORT: port(8001, 'Redis Insight port'), // Redis Connection Settings REDIS_INSIGHT_REDIS_HOSTS: str('local:dragonfly:6379', 'Redis hosts in format name:host:port,name:host:port'), // Configuration REDIS_INSIGHT_LOG_LEVEL: strWithChoices(['error', 'warn', 'info', 'verbose', 'debug'], 'info', 'Redis Insight log level'), REDIS_INSIGHT_DISABLE_ANALYTICS: bool(true, 'Disable analytics collection'), REDIS_INSIGHT_BUILD_TYPE: str('DOCKER', 'Build type identifier'), }); // Export typed configuration objects export type PgAdminConfig = typeof pgAdminConfig; export type MongoExpressConfig = typeof mongoExpressConfig; export type RedisInsightConfig = typeof redisInsightConfig; // Export individual config values for convenience export const { PGADMIN_HOST, PGADMIN_PORT, PGADMIN_DEFAULT_EMAIL, PGADMIN_DEFAULT_PASSWORD, PGADMIN_SERVER_MODE, PGADMIN_DISABLE_POSTFIX, PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION, PGADMIN_MASTER_PASSWORD_REQUIRED, PGADMIN_SESSION_TIMEOUT, } = pgAdminConfig; export const { MONGO_EXPRESS_HOST, MONGO_EXPRESS_PORT, MONGO_EXPRESS_MONGODB_SERVER, MONGO_EXPRESS_MONGODB_PORT, MONGO_EXPRESS_MONGODB_ADMINUSERNAME, MONGO_EXPRESS_MONGODB_ADMINPASSWORD, MONGO_EXPRESS_BASICAUTH_USERNAME, MONGO_EXPRESS_BASICAUTH_PASSWORD, MONGO_EXPRESS_ENABLE_ADMIN, MONGO_EXPRESS_OPTIONS_EDITOR_THEME, MONGO_EXPRESS_REQUEST_SIZE, } = mongoExpressConfig; export const { REDIS_INSIGHT_HOST, REDIS_INSIGHT_PORT, REDIS_INSIGHT_REDIS_HOSTS, REDIS_INSIGHT_LOG_LEVEL, REDIS_INSIGHT_DISABLE_ANALYTICS, REDIS_INSIGHT_BUILD_TYPE, } = redisInsightConfig;