fix(backend): align startup logs and validateConfig with Cosmos-first user store

Made-with: Cursor
This commit is contained in:
Saravana Achu Mac 2026-04-04 18:23:34 -07:00
parent b4d312ce74
commit 1b8740a7f5
2 changed files with 13 additions and 8 deletions

View File

@ -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.');
}
}
}

View File

@ -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) ---