# 26th October 2025 — Environment Variable Centralization and Migration Status [#68](https://github.com/nbarrett/ngx-ramblers/issues/68)
## [build 333](https://github.com/nbarrett/ngx-ramblers/actions/runs/18823789797) — [#68](https://github.com/nbarrett/ngx-ramblers/issues/68) — [commit b93c69b](https://github.com/nbarrett/ngx-ramblers/commit/b93c69b)

Environment configuration refactored with type-safe enum, migration system enhancements for database-driven status, and improved health monitoring.

**Where to Find It**

- **Entire Application**: Environment variable access now type-safe via enum
- **System Status**: Health checks reflect migration state accurately
- **Migration UI**: Consistent filename display across all environments

**Benefits**

- **Type Safety**: Environment variables use TypeScript enums with IDE autocomplete
- **Deployment Reliability**: Server starts even when NODE_ENV not explicitly set (defaults to "development")
- **Consistent Migration Display**: Database-driven status shows same files locally and in production
- **Improved Monitoring**: Health checks accurately reflect migration state for automated alerts
- **Cleaner Logs**: TypeScript declaration files no longer incorrectly identified as migrations
- **Better Maintainability**: Centralized environment variable definitions
- **Database-Driven Status**: Migration state purely from database, independent of environment
- **Improved File Detection**: Filters exclude .d.ts and .d.js files, normalize .ts/.js handling

**Technical Details**

Environment Variable Refactoring:
- Create Environment enum with all application environment variables
- Replace all process.env string literal access with enum references
- Add envConfig.isProduction() helper for NODE_ENV checks
- Use envConfig.booleanValue() for boolean environment variable parsing
- Move booleanOf() to shared string-utils for frontend/backend reuse
- Use existing envConfig wrappers (env, mongo.uri) where available
- Change RUN_MIGRATIONS_ON_STARTUP to SKIP_MIGRATIONS_ON_STARTUP (migrations now run by default)
- Default NODE_ENV to "development" when not set

Migration Status Improvements:
- Fix health endpoint to return 503 when migrations pending
- Update system status check to include pending migrations in health calculation
- Fix site-maintenance component to show correct operational status
- Display Status inline with Applied/Pending/Failed counts
- Add consistent vertical borders to migration table
- Replace console.log with logger in paste-detection service

Migration Filename Normalization:
- Normalize all migration filenames to .js extension for consistency
- Scan for both .ts and .js files on disk but display as .js in UI
- Check database for both .ts and .js versions when determining status
- Ensure migration status is purely database-driven, not environment-dependent
- Update simulated migration filenames to use .js extension