Skip to content

New env loader#8

Merged
MarcosBrendonDePaula merged 8 commits intomainfrom
newEnvLoader
Oct 9, 2025
Merged

New env loader#8
MarcosBrendonDePaula merged 8 commits intomainfrom
newEnvLoader

Conversation

@MarcosBrendonDePaula
Copy link
Copy Markdown
Collaborator

No description provided.

FluxStack Team and others added 8 commits October 9, 2025 09:06
Replaces direct process.env usage with a robust, type-safe config system:

✨ New Features:
- Schema-based configuration with automatic validation
- Full TypeScript type inference (literal types for enums)
- Runtime config reloading capability
- Centralized config management in config/ directory
- Prevents Bun build-time env variable inlining

🏗️ Architecture (3 layers):
1. core/utils/env.ts - Dynamic env loader (prevents inlining)
2. core/utils/config-schema.ts - Schema system with validation
3. config/*.config.ts - Application configs (app, server, logger, etc)

📝 Config Files Added:
- config/app.config.ts - Application settings
- config/server.config.ts - Server configuration
- config/logger.config.ts - Logging configuration
- config/system.config.ts - System runtime info
- config/build.config.ts - Build settings
- config/database.config.ts - Database config (placeholder)
- config/services.config.ts - External services (placeholder)

🔧 Core Changes:
- core/utils/config-schema.ts - Schema system with InferConfig<T>
- core/utils/env.ts - NEW dynamic env loader
- core/config/env.ts - Updated to use new env system
- Removed: env-dynamic.ts, env-runtime.ts, env-runtime-v2.ts

🎯 Application Updates:
- app/server/live/FluxStackConfig.ts - Uses declarative configs
- app/server/routes/config.ts - NEW config inspection endpoint
- All route handlers updated to use typed configs

✅ Benefits:
- Zero 'any' types - full type inference
- Validation at boot time with clear errors
- Single source of truth for configuration
- Better IDE autocomplete and type checking
- Prevents runtime config bugs

🔥 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
Fixes TypeScript errors where minify property was used but not defined in interfaces.

Changes:
- core/config/schema.ts: Add minify to ClientBuildConfig, OptimizationConfig, and BuildConfig
- app/server/index.ts: Add minify: false to client build config

🔥 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Ensures the config/ folder is available in production builds.

Changes:
- core/build/index.ts: Add cpSync import and copy config/ folder after package.json
- Config files are now available at dist/config/ for runtime usage

This is required for the new declarative configuration system to work in production.

🔥 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Adds config/ folder to the list of files copied during project creation.

Changes:
- create-fluxstack.ts: Add 'config' to filesToCopy array

This ensures new projects have the declarative configuration system available.

🔥 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Instead of copying .env directly, now reads and replaces development with production.

Changes:
- core/build/index.ts: Read .env content and replace NODE_ENV values to production
- Both NODE_ENV and VITE_NODE_ENV are set to production in dist/.env

This ensures production builds use the correct environment mode.

🔥 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Updates CLAUDE.md with comprehensive documentation about the new Laravel-inspired config system.

Changes:
- Add section "Sistema de Configuração Declarativa" with examples
- Update architecture diagram to include config/ folder
- Add to "Mudanças Importantes" section
- Include usage examples, helpers, and best practices

Documentation covers:
- Config folder structure
- Schema definition examples
- Type safety and validation
- Available helpers (config.string, config.number, etc.)
- Do's and Don'ts
- Benefits and architecture

🔥 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Creates single source of truth for version number in core/utils/version.ts.

Changes:
- core/utils/version.ts: NEW file with FLUXSTACK_VERSION constant
- core/utils/logger/startup-banner.ts: Import and use FLUXSTACK_VERSION
- package.json: Update version to 1.2.0 and description

Version 1.2.0 includes the new declarative configuration system.

🔥 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@MarcosBrendonDePaula MarcosBrendonDePaula merged commit f81b878 into main Oct 9, 2025
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant