Environment Variables
Configure and manage environment variables in Gconv Prune
Overview
Environment variables are crucial for configuring your Gconv Prune application across different environments. Learn how to properly manage and secure your configuration.
Required Variables
Essential environment variables:
# Core Configuration NODE_ENV=development|production|test PORT=3000 # Database Configuration DATABASE_URL=postgresql://user:pass@host:5432/db # Authentication JWT_SECRET=your-jwt-secret API_KEY=your-api-key # External Services REDIS_URL=redis://localhost:6379 S3_BUCKET=your-bucket-name AWS_ACCESS_KEY=your-access-key AWS_SECRET_KEY=your-secret-key
Environment-Specific Variables
Development
DEBUG=true LOG_LEVEL=debug API_URL=http://localhost:3000
Production
DEBUG=false LOG_LEVEL=info API_URL=https://api.gconvPrune.fun
Security Best Practices
- Never commit .env files to version control
- Use different values for different environments
- Rotate sensitive values regularly
- Use secrets management services in production
Loading Environment Variables
Example of loading environment variables:
import dotenv from "dotenv"; import path from "path"; // Load environment variables based on NODE_ENV const envFile = process.env.NODE_ENV === "production" ? ".env.production" : ".env.development"; dotenv.config({ path: path.resolve(process.cwd(), envFile) });
Validation
Example of environment variable validation:
function validateEnv() { const required = [ "NODE_ENV", "DATABASE_URL", "JWT_SECRET" ]; for (const variable of required) { if (!process.env[variable]) { throw new Error(`Missing required env var: ${variable}`); } } }
Need Help?
For assistance with environment variables, check our troubleshooting guide or contact our support team.