diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index da7e8a3..a76a695 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -446,20 +446,25 @@ export const validateConfig = () => { // Treat "your_key" as empty const isPlaceholder = (val: string) => !val || val === 'your_key' || val === 'your_secret'; + const hasPerUserStoreConfigured = + Boolean(config.COSMOS_ENDPOINT && config.COSMOS_KEY) || + Boolean(config.SUPABASE_URL && config.SUPABASE_KEY); + if (config.PROVIDER === 'alpaca') { if (isPlaceholder(config.ALPACA_API_KEY) || isPlaceholder(config.ALPACA_API_SECRET)) { - // Only log warning, don't exit if Supabase is available - if (config.SUPABASE_URL && config.SUPABASE_KEY) { - logger.warn('⚠️ Alpaca keys in .env are placeholders/missing. Bot will attempt to use keys from Supabase users.'); + if (hasPerUserStoreConfigured) { + logger.warn( + '⚠️ Alpaca keys in .env are placeholders/missing. Bot will attempt to use keys from the configured user store (Cosmos or legacy Supabase).' + ); } else { - logger.error('❌ Missing Alpaca API credentials and no Supabase configured!'); + logger.error('❌ Missing Alpaca API credentials and no user store (Cosmos or Supabase) configured!'); process.exit(1); } } } else if (config.PROVIDER === 'ccxt') { if (!config.EXCHANGE || config.EXCHANGE === 'binance') { // binance is default but check for keys - if (isPlaceholder(config.CCXT_API_KEY) && !(config.SUPABASE_URL)) { - logger.warn('⚠️ CCXT keys are placeholders/missing.'); + if (isPlaceholder(config.CCXT_API_KEY) && !hasPerUserStoreConfigured) { + logger.warn('⚠️ CCXT keys are placeholders/missing and no user store (Cosmos or Supabase) configured.'); } } } diff --git a/backend/src/index.ts b/backend/src/index.ts index 0eaaf53..c9b08e2 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -47,8 +47,8 @@ async function main() { if (typeof dynamicConfigRefreshTimer.unref === 'function') { dynamicConfigRefreshTimer.unref(); } - // --- 0. Load User Configuration (Supabase) --- - logger.info('Fetching active users from Supabase...'); + // --- 0. Load user configuration (Cosmos-first; legacy Supabase optional) --- + logger.info('Fetching active trading users...'); let users = await listActiveTradingUsers(supabaseService); // --- 1. Identify Primary Key (for Data Fetching) ---