import fetch from 'node-fetch'; import * as dotenv from 'dotenv'; dotenv.config(); const HF_TOKEN = process.env.HUGGINGFACE_TOKEN; const SPACE_ID = 'wbes/executive-suites'; interface Secret { key: string; value: string; } async function setupSecrets() { console.log('🔐 Setting up Hugging Face secrets...'); if (!HF_TOKEN) { throw new Error('HUGGINGFACE_TOKEN not found in environment'); } const secrets: Secret[] = [ { key: 'DATABASE_URL', value: process.env.DATABASE_URL || '' }, { key: 'NEXTAUTH_SECRET', value: process.env.NEXTAUTH_SECRET || '' }, { key: 'NEXTAUTH_URL', value: process.env.NEXTAUTH_URL || '' } ]; try { for (const secret of secrets) { if (!secret.value) { console.warn(`⚠️ Warning: ${secret.key} is empty`); continue; } const response = await fetch( `https://huggingface.co/api/spaces/${SPACE_ID}/secrets/${secret.key}`, { method: 'PUT', headers: { 'Authorization': `Bearer ${HF_TOKEN}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ value: secret.value }) } ); if (!response.ok) { throw new Error(`Failed to set ${secret.key}: ${response.statusText}`); } console.log(`✅ Set ${secret.key}`); } console.log('✅ All secrets configured successfully!'); } catch (error) { console.error('❌ Failed to set secrets:', error); process.exit(1); } } setupSecrets();