fix(backend): align startup logs and validateConfig with Cosmos-first user store
Made-with: Cursor
This commit is contained in:
parent
b4d312ce74
commit
1b8740a7f5
@ -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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) ---
|
||||
|
||||
Loading…
Reference in New Issue
Block a user