| /** | |
| * Scripts: Validate Environment | |
| * Checks all required env vars before deployment | |
| */ | |
| const REQUIRED_SIMULATOR_VARS = [ | |
| 'OPENAI_API_KEY', | |
| 'N8N_BASE_URL', | |
| 'N8N_API_KEY', | |
| 'INTERNAL_API_SECRET', | |
| ]; | |
| const REQUIRED_WORKER_SECRETS = [ | |
| 'OPENAI_API_KEY', | |
| 'N8N_API_KEY', | |
| 'INTERNAL_API_SECRET', | |
| ]; | |
| let hasError = false; | |
| console.log('[ValidateEnv] Checking Simulator service environment variables...'); | |
| for (const key of REQUIRED_SIMULATOR_VARS) { | |
| if (!process.env[key]) { | |
| console.error(` β Missing: ${key}`); | |
| hasError = true; | |
| } else { | |
| console.log(` β ${key}`); | |
| } | |
| } | |
| console.log(''); | |
| console.log('[ValidateEnv] Cloudflare Worker secrets (set via wrangler secret put):'); | |
| for (const key of REQUIRED_WORKER_SECRETS) { | |
| console.log(` β wrangler secret put ${key}`); | |
| } | |
| if (hasError) { | |
| console.error('\n[ValidateEnv] β Environment validation failed. Set missing variables before deploying.'); | |
| process.exit(1); | |
| } else { | |
| console.log('\n[ValidateEnv] β All environment variables present.'); | |
| } | |