Environment Verification Script Setup
This guide shows how to add the environment verification script to each Factory app.Quick Setup
1. Copy the script to your app
2. Add npm scripts to package.json
3. Add .dev.vars.example to your app
.dev.vars by copying and filling in the template:
4. Test the verification
What the Script Does
Checks for Local Development (npm run verify:env)
- β wrangler.jsonc exists
- β src/env.ts exists
- β src/index.ts exists
- β .dev.vars exists and has values (not empty)
- β Worker name doesnβt contain β-stagingβ (local naming)
- β Hyperdrive binding configured (DB)
- β Rate limiter binding configured (AUTH_RATE_LIMITER)
- β /health endpoint defined in src/index.ts
- β All required environment fields declared in src/env.ts
- β All required values set in .dev.vars
Checks for Staging (npm run verify:env:staging)
Same as local, plus:
- β Worker name contains β-stagingβ
Checks for Production (npm run verify:env:production)
Same as local, but:
- β Worker name does NOT contain β-stagingβ
Usage Examples
Before Starting Local Dev
Before Deploying to Staging
Before Deploying to Production
Integrated into Dev Startup
Edit package.json:npm run dev always verifies environment first:
Script Output Examples
Success
Failure
Customizing the Script
The script is highly customizable. Editscripts/verify-env.js: