WestBocaExecutiveSuites / scripts /setup-hf-secrets.ts
Demon1212122's picture
chore: reapply local updates
fb14972
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();