Download scripts/setup-hf-secrets.ts from WBES/WestBocaExecutiveSuites: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/WBES/WestBocaExecutiveSuites/resolve/main/scripts/setup-hf-secrets.ts
- Command line
-
hf download hf://WBES/WestBocaExecutiveSuites/scripts/setup-hf-secrets.ts
-
curl -L -o setup-hf-secrets.ts https://huggingface.co/WBES/WestBocaExecutiveSuites/resolve/main/scripts/setup-hf-secrets.ts
1.73 kB
| 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(); |