import fs from 'fs';
import path from 'path';

export function loadN8nBillingApiKey() {
  if (process.env.N8N_BILLING_API_KEY) return process.env.N8N_BILLING_API_KEY;
  const keyPath = path.join(process.cwd(), 'creds', 'n8n-billing.key');
  try {
    return fs.readFileSync(keyPath, 'utf8').trim();
  } catch {
    return null;
  }
}
