create-fluxstack 1.0.22 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/server/backend-only.ts +5 -5
- package/app/server/index.ts +63 -54
- package/app/server/live/FluxStackConfig.ts +43 -39
- package/app/server/live/SystemMonitorIntegration.ts +2 -2
- package/app/server/live/register-components.ts +6 -26
- package/app/server/middleware/errorHandling.ts +6 -4
- package/app/server/routes/config.ts +145 -0
- package/app/server/routes/index.ts +5 -3
- package/config/app.config.ts +113 -0
- package/config/build.config.ts +24 -0
- package/config/database.config.ts +99 -0
- package/config/index.ts +68 -0
- package/config/logger.config.ts +27 -0
- package/config/runtime.config.ts +92 -0
- package/config/server.config.ts +46 -0
- package/config/services.config.ts +130 -0
- package/config/system.config.ts +105 -0
- package/core/build/bundler.ts +53 -5
- package/core/build/flux-plugins-generator.ts +315 -0
- package/core/build/index.ts +11 -7
- package/core/build/live-components-generator.ts +231 -0
- package/core/build/optimizer.ts +2 -54
- package/core/cli/index.ts +31 -13
- package/core/config/env.ts +38 -94
- package/core/config/runtime-config.ts +61 -58
- package/core/config/schema.ts +1 -0
- package/core/framework/server.ts +55 -11
- package/core/plugins/built-in/index.ts +7 -17
- package/core/plugins/built-in/static/index.ts +24 -10
- package/core/plugins/built-in/swagger/index.ts +228 -228
- package/core/plugins/built-in/vite/index.ts +374 -358
- package/core/plugins/dependency-manager.ts +5 -5
- package/core/plugins/manager.ts +57 -14
- package/core/plugins/registry.ts +3 -3
- package/core/server/index.ts +0 -1
- package/core/server/live/ComponentRegistry.ts +34 -8
- package/core/server/live/LiveComponentPerformanceMonitor.ts +1 -1
- package/core/server/live/websocket-plugin.ts +434 -434
- package/core/server/middleware/README.md +488 -0
- package/core/server/middleware/elysia-helpers.ts +227 -0
- package/core/server/middleware/index.ts +25 -9
- package/core/server/plugins/static-files-plugin.ts +231 -231
- package/core/utils/config-schema.ts +484 -0
- package/core/utils/env.ts +306 -0
- package/core/utils/helpers.ts +9 -3
- package/core/utils/logger/colors.ts +114 -0
- package/core/utils/logger/config.ts +35 -0
- package/core/utils/logger/formatter.ts +82 -0
- package/core/utils/logger/group-logger.ts +101 -0
- package/core/utils/logger/index.ts +199 -250
- package/core/utils/logger/stack-trace.ts +92 -0
- package/core/utils/logger/startup-banner.ts +92 -0
- package/core/utils/logger/winston-logger.ts +152 -0
- package/core/utils/version.ts +5 -0
- package/create-fluxstack.ts +1 -0
- package/fluxstack.config.ts +6 -12
- package/package.json +117 -114
- package/plugins/crypto-auth/README.md +238 -0
- package/plugins/crypto-auth/client/CryptoAuthClient.ts +325 -0
- package/plugins/crypto-auth/client/components/AuthProvider.tsx +190 -0
- package/plugins/crypto-auth/client/components/LoginButton.tsx +155 -0
- package/plugins/crypto-auth/client/components/ProtectedRoute.tsx +109 -0
- package/plugins/crypto-auth/client/components/SessionInfo.tsx +242 -0
- package/plugins/crypto-auth/client/components/index.ts +15 -0
- package/plugins/crypto-auth/client/index.ts +12 -0
- package/plugins/crypto-auth/index.ts +230 -0
- package/plugins/crypto-auth/package.json +65 -0
- package/plugins/crypto-auth/plugin.json +29 -0
- package/plugins/crypto-auth/server/AuthMiddleware.ts +237 -0
- package/plugins/crypto-auth/server/CryptoAuthService.ts +293 -0
- package/plugins/crypto-auth/server/index.ts +9 -0
- package/vite.config.ts +16 -0
- package/core/config/env-dynamic.ts +0 -326
- package/core/plugins/built-in/logger/index.ts +0 -180
- package/core/server/plugins/logger.ts +0 -47
- package/core/utils/env-runtime-v2.ts +0 -232
- package/core/utils/env-runtime.ts +0 -259
- package/core/utils/logger/formatters.ts +0 -222
- package/core/utils/logger/middleware.ts +0 -253
- package/core/utils/logger/performance.ts +0 -384
- package/core/utils/logger/transports.ts +0 -365
- package/core/utils/logger.ts +0 -106
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// 🚀 FluxStack Live Components - Auto Registration Generator
|
|
2
|
+
// Automatically generates component registration during build time
|
|
3
|
+
|
|
4
|
+
import { existsSync, readdirSync, writeFileSync, unlinkSync, readFileSync } from 'fs'
|
|
5
|
+
import { join, extname, basename } from 'path'
|
|
6
|
+
|
|
7
|
+
export interface ComponentInfo {
|
|
8
|
+
fileName: string
|
|
9
|
+
className: string
|
|
10
|
+
componentName: string
|
|
11
|
+
filePath: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class LiveComponentsGenerator {
|
|
15
|
+
private componentsPath: string
|
|
16
|
+
private registrationFilePath: string
|
|
17
|
+
private backupFilePath: string
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
this.componentsPath = join(process.cwd(), 'app', 'server', 'live')
|
|
21
|
+
this.registrationFilePath = join(process.cwd(), 'app', 'server', 'live', 'register-components.ts')
|
|
22
|
+
this.backupFilePath = join(process.cwd(), 'app', 'server', 'live', 'register-components.backup.ts')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Scan the live components directory and discover all components
|
|
27
|
+
*/
|
|
28
|
+
discoverComponents(): ComponentInfo[] {
|
|
29
|
+
if (!existsSync(this.componentsPath)) {
|
|
30
|
+
console.log('⚠️ Live components directory not found:', this.componentsPath)
|
|
31
|
+
return []
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const components: ComponentInfo[] = []
|
|
35
|
+
const files = readdirSync(this.componentsPath)
|
|
36
|
+
|
|
37
|
+
for (const file of files) {
|
|
38
|
+
// Skip non-TypeScript files, backup files, and the registration file itself
|
|
39
|
+
if (!file.endsWith('.ts') ||
|
|
40
|
+
file === 'register-components.ts' ||
|
|
41
|
+
file.includes('.backup.') ||
|
|
42
|
+
file.includes('.bak')) {
|
|
43
|
+
continue
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const filePath = join(this.componentsPath, file)
|
|
47
|
+
const fileName = basename(file, extname(file))
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
// Read file content to extract class name
|
|
51
|
+
const content = readFileSync(filePath, 'utf-8')
|
|
52
|
+
|
|
53
|
+
// Look for class exports that extend LiveComponent
|
|
54
|
+
const classMatches = content.match(/export\s+class\s+(\w+)\s+extends\s+LiveComponent/g)
|
|
55
|
+
|
|
56
|
+
if (classMatches && classMatches.length > 0) {
|
|
57
|
+
for (const match of classMatches) {
|
|
58
|
+
const classNameMatch = match.match(/class\s+(\w+)/)
|
|
59
|
+
if (classNameMatch) {
|
|
60
|
+
const className = classNameMatch[1]
|
|
61
|
+
const componentName = className.replace(/Component$/, '')
|
|
62
|
+
|
|
63
|
+
components.push({
|
|
64
|
+
fileName,
|
|
65
|
+
className,
|
|
66
|
+
componentName,
|
|
67
|
+
filePath: `./${fileName}`
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
console.log(`🔍 Discovered component: ${className} -> ${componentName}`)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.warn(`⚠️ Failed to analyze ${file}:`, error)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return components
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Generate the registration file with all discovered components
|
|
84
|
+
*/
|
|
85
|
+
generateRegistrationFile(components: ComponentInfo[]): void {
|
|
86
|
+
// Backup existing file if it exists
|
|
87
|
+
if (existsSync(this.registrationFilePath)) {
|
|
88
|
+
const existingContent = readFileSync(this.registrationFilePath, 'utf-8')
|
|
89
|
+
writeFileSync(this.backupFilePath, existingContent)
|
|
90
|
+
console.log('📄 Backed up existing register-components.ts')
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Generate imports
|
|
94
|
+
const imports = components
|
|
95
|
+
.map(comp => `import { ${comp.className} } from "${comp.filePath}"`)
|
|
96
|
+
.join('\n')
|
|
97
|
+
|
|
98
|
+
// Generate registrations
|
|
99
|
+
const registrations = components
|
|
100
|
+
.map(comp => ` componentRegistry.registerComponentClass('${comp.componentName}', ${comp.className})`)
|
|
101
|
+
.join('\n')
|
|
102
|
+
|
|
103
|
+
// Generate file content
|
|
104
|
+
const fileContent = `// 🔥 Auto-generated Live Components Registration
|
|
105
|
+
// This file is automatically generated during build time - DO NOT EDIT MANUALLY
|
|
106
|
+
// Generated at: ${new Date().toISOString()}
|
|
107
|
+
|
|
108
|
+
${imports}
|
|
109
|
+
import { componentRegistry } from "@/core/server/live/ComponentRegistry"
|
|
110
|
+
|
|
111
|
+
// Register all components statically for production bundle
|
|
112
|
+
function registerAllComponents() {
|
|
113
|
+
try {
|
|
114
|
+
// Auto-generated component registrations
|
|
115
|
+
${registrations}
|
|
116
|
+
|
|
117
|
+
console.log('📝 Live components registered successfully! (${components.length} components)')
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.warn('⚠️ Error registering components:', error)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Auto-register components
|
|
124
|
+
registerAllComponents()
|
|
125
|
+
|
|
126
|
+
// Export all components to ensure they're included in the bundle
|
|
127
|
+
export {
|
|
128
|
+
${components.map(comp => ` ${comp.className}`).join(',\n')}
|
|
129
|
+
}
|
|
130
|
+
`
|
|
131
|
+
|
|
132
|
+
writeFileSync(this.registrationFilePath, fileContent)
|
|
133
|
+
console.log(`✅ Generated registration file with ${components.length} components`)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Restore the original registration file from backup
|
|
138
|
+
*/
|
|
139
|
+
restoreOriginalFile(): void {
|
|
140
|
+
if (existsSync(this.backupFilePath)) {
|
|
141
|
+
const backupContent = readFileSync(this.backupFilePath, 'utf-8')
|
|
142
|
+
writeFileSync(this.registrationFilePath, backupContent)
|
|
143
|
+
unlinkSync(this.backupFilePath)
|
|
144
|
+
console.log('🔄 Restored original register-components.ts')
|
|
145
|
+
} else {
|
|
146
|
+
console.log('⚠️ No backup file found, keeping generated registration file')
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Check if the current registration file is auto-generated
|
|
152
|
+
*/
|
|
153
|
+
isAutoGenerated(): boolean {
|
|
154
|
+
if (!existsSync(this.registrationFilePath)) {
|
|
155
|
+
return false
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const content = readFileSync(this.registrationFilePath, 'utf-8')
|
|
159
|
+
return content.includes('// 🔥 Auto-generated Live Components Registration')
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Pre-build hook: Generate registration file
|
|
164
|
+
*/
|
|
165
|
+
async preBuild(): Promise<ComponentInfo[]> {
|
|
166
|
+
console.log('🚀 [PRE-BUILD] Generating Live Components registration...')
|
|
167
|
+
|
|
168
|
+
const components = this.discoverComponents()
|
|
169
|
+
|
|
170
|
+
if (components.length === 0) {
|
|
171
|
+
console.log('⚠️ No Live Components found to register')
|
|
172
|
+
return []
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
this.generateRegistrationFile(components)
|
|
176
|
+
|
|
177
|
+
return components
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Post-build hook: Clean up generated file (optional)
|
|
182
|
+
*/
|
|
183
|
+
async postBuild(keepGenerated: boolean = false): Promise<void> {
|
|
184
|
+
console.log('🧹 [POST-BUILD] Cleaning up Live Components registration...')
|
|
185
|
+
|
|
186
|
+
if (keepGenerated) {
|
|
187
|
+
console.log('📝 Keeping auto-generated registration file for production')
|
|
188
|
+
// Remove backup since we're keeping the generated version
|
|
189
|
+
if (existsSync(this.backupFilePath)) {
|
|
190
|
+
unlinkSync(this.backupFilePath)
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
this.restoreOriginalFile()
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Development mode: Check if registration needs update
|
|
199
|
+
*/
|
|
200
|
+
needsUpdate(): boolean {
|
|
201
|
+
if (!this.isAutoGenerated()) {
|
|
202
|
+
return false // Manual file, don't touch
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const components = this.discoverComponents()
|
|
206
|
+
const currentContent = readFileSync(this.registrationFilePath, 'utf-8')
|
|
207
|
+
|
|
208
|
+
// Check if all discovered components are in the current file
|
|
209
|
+
for (const comp of components) {
|
|
210
|
+
if (!currentContent.includes(`'${comp.componentName}', ${comp.className}`)) {
|
|
211
|
+
return true
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return false
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Development mode: Update registration if needed
|
|
220
|
+
*/
|
|
221
|
+
updateIfNeeded(): void {
|
|
222
|
+
if (this.needsUpdate()) {
|
|
223
|
+
console.log('🔄 Live Components changed, updating registration...')
|
|
224
|
+
const components = this.discoverComponents()
|
|
225
|
+
this.generateRegistrationFile(components)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Export singleton instance
|
|
231
|
+
export const liveComponentsGenerator = new LiveComponentsGenerator()
|
package/core/build/optimizer.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { gzipSync } from "zlib"
|
|
|
4
4
|
import type { OptimizationConfig, OptimizationResult } from "../types/build"
|
|
5
5
|
|
|
6
6
|
export interface OptimizerConfig {
|
|
7
|
-
minify: boolean
|
|
8
7
|
treeshake: boolean
|
|
9
8
|
compress: boolean
|
|
10
9
|
removeUnusedCSS: boolean
|
|
@@ -36,10 +35,7 @@ export class Optimizer {
|
|
|
36
35
|
// Get original size
|
|
37
36
|
results.originalSize = await this.calculateDirectorySize(buildPath)
|
|
38
37
|
|
|
39
|
-
// Apply optimizations
|
|
40
|
-
if (this.config.minify) {
|
|
41
|
-
await this.minifyAssets(buildPath, results)
|
|
42
|
-
}
|
|
38
|
+
// Apply optimizations (minification removed for compatibility)
|
|
43
39
|
|
|
44
40
|
if (this.config.compress) {
|
|
45
41
|
await this.compressAssets(buildPath, results)
|
|
@@ -80,55 +76,7 @@ export class Optimizer {
|
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
78
|
|
|
83
|
-
|
|
84
|
-
console.log("🗜️ Minifying assets...")
|
|
85
|
-
|
|
86
|
-
const files = this.getFilesRecursively(buildPath)
|
|
87
|
-
let minifiedCount = 0
|
|
88
|
-
|
|
89
|
-
for (const file of files) {
|
|
90
|
-
const ext = extname(file).toLowerCase()
|
|
91
|
-
|
|
92
|
-
if (ext === '.js' || ext === '.css') {
|
|
93
|
-
try {
|
|
94
|
-
const content = readFileSync(file, 'utf-8')
|
|
95
|
-
const minified = await this.minifyContent(content, ext)
|
|
96
|
-
|
|
97
|
-
if (minified !== content) {
|
|
98
|
-
writeFileSync(file, minified)
|
|
99
|
-
minifiedCount++
|
|
100
|
-
}
|
|
101
|
-
} catch (error) {
|
|
102
|
-
console.warn(`⚠️ Failed to minify ${file}:`, error)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
results.optimizations.push({
|
|
108
|
-
type: 'minification',
|
|
109
|
-
description: `Minified ${minifiedCount} files`,
|
|
110
|
-
sizeSaved: 0 // Would calculate actual size saved
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private async minifyContent(content: string, type: string): Promise<string> {
|
|
115
|
-
// Basic minification - in a real implementation, you'd use proper minifiers
|
|
116
|
-
if (type === '.js') {
|
|
117
|
-
return content
|
|
118
|
-
.replace(/\/\*[\s\S]*?\*\//g, '') // Remove comments
|
|
119
|
-
.replace(/\/\/.*$/gm, '') // Remove single-line comments
|
|
120
|
-
.replace(/\s+/g, ' ') // Collapse whitespace
|
|
121
|
-
.trim()
|
|
122
|
-
} else if (type === '.css') {
|
|
123
|
-
return content
|
|
124
|
-
.replace(/\/\*[\s\S]*?\*\//g, '') // Remove comments
|
|
125
|
-
.replace(/\s+/g, ' ') // Collapse whitespace
|
|
126
|
-
.replace(/;\s*}/g, '}') // Remove unnecessary semicolons
|
|
127
|
-
.trim()
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return content
|
|
131
|
-
}
|
|
79
|
+
// Minification methods removed for compatibility with Bun bundler
|
|
132
80
|
|
|
133
81
|
private async compressAssets(buildPath: string, results: OptimizationResult): Promise<void> {
|
|
134
82
|
console.log("📦 Compressing assets...")
|
package/core/cli/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { getConfigSync } from "../config"
|
|
|
6
6
|
import { cliRegistry } from "./command-registry"
|
|
7
7
|
import { pluginDiscovery } from "./plugin-discovery"
|
|
8
8
|
import { generateCommand, interactiveGenerateCommand } from "./generators/index.js"
|
|
9
|
+
import { startGroup, endGroup, logBox, logInGroup } from "../utils/logger/group-logger"
|
|
9
10
|
|
|
10
11
|
const command = process.argv[2]
|
|
11
12
|
const args = process.argv.slice(3)
|
|
@@ -134,12 +135,20 @@ Examples:
|
|
|
134
135
|
}
|
|
135
136
|
],
|
|
136
137
|
handler: async (args, options, context) => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
// Grouped startup messages
|
|
139
|
+
startGroup({
|
|
140
|
+
title: 'FluxStack Development Server',
|
|
141
|
+
icon: '⚡',
|
|
142
|
+
color: 'cyan'
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
logInGroup(`Frontend: http://localhost:${options['frontend-port']}`, '🌐')
|
|
146
|
+
logInGroup(`Backend: http://localhost:${options.port}`, '🚀')
|
|
147
|
+
logInGroup('Backend inicia Vite programaticamente', '🔄')
|
|
148
|
+
logInGroup('Starting backend server...', '📦')
|
|
149
|
+
|
|
150
|
+
endGroup()
|
|
151
|
+
console.log('') // Separator line
|
|
143
152
|
|
|
144
153
|
const { spawn } = await import("child_process")
|
|
145
154
|
const devProcess = spawn("bun", ["--watch", "app/server/index.ts"], {
|
|
@@ -293,12 +302,20 @@ async function main() {
|
|
|
293
302
|
async function handleLegacyCommands() {
|
|
294
303
|
switch (command) {
|
|
295
304
|
case "dev":
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
305
|
+
// Grouped startup messages
|
|
306
|
+
startGroup({
|
|
307
|
+
title: 'FluxStack Development Server',
|
|
308
|
+
icon: '⚡',
|
|
309
|
+
color: 'cyan'
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
logInGroup('Frontend: http://localhost:5173', '🌐')
|
|
313
|
+
logInGroup('Backend: http://localhost:3000', '🚀')
|
|
314
|
+
logInGroup('Backend inicia Vite programaticamente', '🔄')
|
|
315
|
+
logInGroup('Starting backend server...', '📦')
|
|
316
|
+
|
|
317
|
+
endGroup()
|
|
318
|
+
console.log('') // Separator line
|
|
302
319
|
|
|
303
320
|
// Start only backend - it will start Vite programmatically
|
|
304
321
|
const { spawn } = await import("child_process")
|
|
@@ -385,7 +402,8 @@ async function handleLegacyCommands() {
|
|
|
385
402
|
|
|
386
403
|
case "start":
|
|
387
404
|
console.log("🚀 Starting FluxStack production server...")
|
|
388
|
-
await import(
|
|
405
|
+
const { join } = await import("path")
|
|
406
|
+
await import(join(process.cwd(), "dist", "index.js"))
|
|
389
407
|
break
|
|
390
408
|
|
|
391
409
|
case "create":
|
package/core/config/env.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Handles environment variable processing and precedence
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { env, helpers } from '../utils/env'
|
|
6
7
|
import type { FluxStackConfig, LogLevel, BuildTarget, LogFormat } from './schema'
|
|
7
8
|
|
|
8
9
|
export interface EnvironmentInfo {
|
|
@@ -24,7 +25,7 @@ export interface ConfigPrecedence {
|
|
|
24
25
|
* Get current environment information
|
|
25
26
|
*/
|
|
26
27
|
export function getEnvironmentInfo(): EnvironmentInfo {
|
|
27
|
-
const nodeEnv =
|
|
28
|
+
const nodeEnv = env.NODE_ENV
|
|
28
29
|
|
|
29
30
|
return {
|
|
30
31
|
name: nodeEnv,
|
|
@@ -97,117 +98,60 @@ export class EnvironmentProcessor {
|
|
|
97
98
|
const config: any = {}
|
|
98
99
|
|
|
99
100
|
// App configuration
|
|
100
|
-
this.setConfigValue(config, 'app.name',
|
|
101
|
-
|
|
102
|
-
this.setConfigValue(config, 'app.version',
|
|
103
|
-
process.env.FLUXSTACK_APP_VERSION || process.env.APP_VERSION, 'string')
|
|
104
|
-
this.setConfigValue(config, 'app.description',
|
|
105
|
-
process.env.FLUXSTACK_APP_DESCRIPTION || process.env.APP_DESCRIPTION, 'string')
|
|
101
|
+
this.setConfigValue(config, 'app.name', env.FLUXSTACK_APP_NAME, 'string')
|
|
102
|
+
this.setConfigValue(config, 'app.version', env.FLUXSTACK_APP_VERSION, 'string')
|
|
106
103
|
|
|
107
104
|
// Server configuration
|
|
108
|
-
this.setConfigValue(config, 'server.port',
|
|
109
|
-
|
|
110
|
-
this.setConfigValue(config, 'server.
|
|
111
|
-
process.env.HOST || process.env.FLUXSTACK_HOST, 'string')
|
|
112
|
-
this.setConfigValue(config, 'server.apiPrefix',
|
|
113
|
-
process.env.FLUXSTACK_API_PREFIX || process.env.API_PREFIX, 'string')
|
|
105
|
+
this.setConfigValue(config, 'server.port', env.PORT?.toString(), 'number')
|
|
106
|
+
this.setConfigValue(config, 'server.host', env.HOST, 'string')
|
|
107
|
+
this.setConfigValue(config, 'server.apiPrefix', env.API_PREFIX, 'string')
|
|
114
108
|
|
|
115
109
|
// CORS configuration
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.setConfigValue(config, 'server.cors.
|
|
121
|
-
|
|
122
|
-
this.setConfigValue(config, 'server.cors.
|
|
123
|
-
|
|
124
|
-
this.setConfigValue(config, 'server.cors.maxAge',
|
|
125
|
-
process.env.CORS_MAX_AGE || process.env.FLUXSTACK_CORS_MAX_AGE, 'number')
|
|
110
|
+
const corsOriginsStr = env.has('CORS_ORIGINS') ? env.all().CORS_ORIGINS : undefined
|
|
111
|
+
const corsMethodsStr = env.has('CORS_METHODS') ? env.all().CORS_METHODS : undefined
|
|
112
|
+
const corsHeadersStr = env.has('CORS_HEADERS') ? env.all().CORS_HEADERS : undefined
|
|
113
|
+
|
|
114
|
+
this.setConfigValue(config, 'server.cors.origins', corsOriginsStr, 'array')
|
|
115
|
+
this.setConfigValue(config, 'server.cors.methods', corsMethodsStr, 'array')
|
|
116
|
+
this.setConfigValue(config, 'server.cors.headers', corsHeadersStr, 'array')
|
|
117
|
+
this.setConfigValue(config, 'server.cors.credentials', env.CORS_CREDENTIALS?.toString(), 'boolean')
|
|
118
|
+
this.setConfigValue(config, 'server.cors.maxAge', env.CORS_MAX_AGE?.toString(), 'number')
|
|
126
119
|
|
|
127
120
|
// Client configuration
|
|
128
|
-
this.setConfigValue(config, 'client.port',
|
|
129
|
-
process.env.VITE_PORT || process.env.CLIENT_PORT || process.env.FLUXSTACK_CLIENT_PORT, 'number')
|
|
130
|
-
this.setConfigValue(config, 'client.proxy.target',
|
|
131
|
-
process.env.VITE_API_URL || process.env.API_URL || process.env.FLUXSTACK_PROXY_TARGET, 'string')
|
|
132
|
-
this.setConfigValue(config, 'client.build.sourceMaps',
|
|
133
|
-
process.env.FLUXSTACK_CLIENT_SOURCEMAPS, 'boolean')
|
|
134
|
-
this.setConfigValue(config, 'client.build.minify',
|
|
135
|
-
process.env.FLUXSTACK_CLIENT_MINIFY, 'boolean')
|
|
121
|
+
this.setConfigValue(config, 'client.port', env.VITE_PORT?.toString(), 'number')
|
|
136
122
|
|
|
137
123
|
// Build configuration
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.setConfigValue(config, 'build.outDir',
|
|
141
|
-
process.env.BUILD_OUTDIR || process.env.FLUXSTACK_BUILD_OUTDIR, 'string')
|
|
142
|
-
this.setConfigValue(config, 'build.sourceMaps',
|
|
143
|
-
process.env.BUILD_SOURCEMAPS || process.env.FLUXSTACK_BUILD_SOURCEMAPS, 'boolean')
|
|
144
|
-
this.setConfigValue(config, 'build.clean',
|
|
145
|
-
process.env.BUILD_CLEAN || process.env.FLUXSTACK_BUILD_CLEAN, 'boolean')
|
|
146
|
-
|
|
147
|
-
// Build optimization
|
|
148
|
-
this.setConfigValue(config, 'build.optimization.minify',
|
|
149
|
-
process.env.BUILD_MINIFY || process.env.FLUXSTACK_BUILD_MINIFY, 'boolean')
|
|
150
|
-
this.setConfigValue(config, 'build.optimization.treeshake',
|
|
151
|
-
process.env.BUILD_TREESHAKE || process.env.FLUXSTACK_BUILD_TREESHAKE, 'boolean')
|
|
152
|
-
this.setConfigValue(config, 'build.optimization.compress',
|
|
153
|
-
process.env.BUILD_COMPRESS || process.env.FLUXSTACK_BUILD_COMPRESS, 'boolean')
|
|
154
|
-
this.setConfigValue(config, 'build.optimization.splitChunks',
|
|
155
|
-
process.env.BUILD_SPLIT_CHUNKS || process.env.FLUXSTACK_BUILD_SPLIT_CHUNKS, 'boolean')
|
|
156
|
-
this.setConfigValue(config, 'build.optimization.bundleAnalyzer',
|
|
157
|
-
process.env.BUILD_ANALYZER || process.env.FLUXSTACK_BUILD_ANALYZER, 'boolean')
|
|
124
|
+
const buildMinify = env.has('BUILD_MINIFY') ? env.all().BUILD_MINIFY : undefined
|
|
125
|
+
this.setConfigValue(config, 'build.optimization.minify', buildMinify, 'boolean')
|
|
158
126
|
|
|
159
127
|
// Logging configuration
|
|
160
|
-
this.setConfigValue(config, 'logging.level',
|
|
161
|
-
|
|
162
|
-
this.setConfigValue(config, 'logging.format',
|
|
163
|
-
process.env.LOG_FORMAT || process.env.FLUXSTACK_LOG_FORMAT, 'logFormat')
|
|
128
|
+
this.setConfigValue(config, 'logging.level', env.LOG_LEVEL, 'logLevel')
|
|
129
|
+
this.setConfigValue(config, 'logging.format', env.LOG_FORMAT, 'logFormat')
|
|
164
130
|
|
|
165
131
|
// Monitoring configuration
|
|
166
|
-
this.setConfigValue(config, 'monitoring.enabled',
|
|
167
|
-
|
|
168
|
-
this.setConfigValue(config, 'monitoring.metrics.enabled',
|
|
169
|
-
process.env.METRICS_ENABLED || process.env.FLUXSTACK_METRICS_ENABLED, 'boolean')
|
|
170
|
-
this.setConfigValue(config, 'monitoring.metrics.collectInterval',
|
|
171
|
-
process.env.METRICS_INTERVAL || process.env.FLUXSTACK_METRICS_INTERVAL, 'number')
|
|
172
|
-
this.setConfigValue(config, 'monitoring.profiling.enabled',
|
|
173
|
-
process.env.PROFILING_ENABLED || process.env.FLUXSTACK_PROFILING_ENABLED, 'boolean')
|
|
174
|
-
this.setConfigValue(config, 'monitoring.profiling.sampleRate',
|
|
175
|
-
process.env.PROFILING_SAMPLE_RATE || process.env.FLUXSTACK_PROFILING_SAMPLE_RATE, 'number')
|
|
132
|
+
this.setConfigValue(config, 'monitoring.enabled', env.ENABLE_MONITORING?.toString(), 'boolean')
|
|
133
|
+
this.setConfigValue(config, 'monitoring.metrics.enabled', env.ENABLE_METRICS?.toString(), 'boolean')
|
|
176
134
|
|
|
177
135
|
// Database configuration
|
|
178
|
-
this.setConfigValue(config, 'database.url',
|
|
179
|
-
this.setConfigValue(config, 'database.host',
|
|
180
|
-
this.setConfigValue(config, 'database.port',
|
|
181
|
-
this.setConfigValue(config, 'database.database',
|
|
182
|
-
this.setConfigValue(config, 'database.user',
|
|
183
|
-
this.setConfigValue(config, 'database.password',
|
|
184
|
-
this.setConfigValue(config, 'database.ssl',
|
|
185
|
-
this.setConfigValue(config, 'database.poolSize', process.env.DATABASE_POOL_SIZE, 'number')
|
|
136
|
+
this.setConfigValue(config, 'database.url', env.DATABASE_URL, 'string')
|
|
137
|
+
this.setConfigValue(config, 'database.host', env.DB_HOST, 'string')
|
|
138
|
+
this.setConfigValue(config, 'database.port', env.DB_PORT?.toString(), 'number')
|
|
139
|
+
this.setConfigValue(config, 'database.database', env.DB_NAME, 'string')
|
|
140
|
+
this.setConfigValue(config, 'database.user', env.DB_USER, 'string')
|
|
141
|
+
this.setConfigValue(config, 'database.password', env.DB_PASSWORD, 'string')
|
|
142
|
+
this.setConfigValue(config, 'database.ssl', env.DB_SSL?.toString(), 'boolean')
|
|
186
143
|
|
|
187
144
|
// Auth configuration
|
|
188
|
-
this.setConfigValue(config, 'auth.secret',
|
|
189
|
-
this.setConfigValue(config, 'auth.expiresIn',
|
|
190
|
-
this.setConfigValue(config, 'auth.algorithm',
|
|
191
|
-
this.setConfigValue(config, 'auth.issuer', process.env.JWT_ISSUER, 'string')
|
|
145
|
+
this.setConfigValue(config, 'auth.secret', env.JWT_SECRET, 'string')
|
|
146
|
+
this.setConfigValue(config, 'auth.expiresIn', env.JWT_EXPIRES_IN, 'string')
|
|
147
|
+
this.setConfigValue(config, 'auth.algorithm', env.JWT_ALGORITHM, 'string')
|
|
192
148
|
|
|
193
149
|
// Email configuration
|
|
194
|
-
this.setConfigValue(config, 'email.host',
|
|
195
|
-
this.setConfigValue(config, 'email.port',
|
|
196
|
-
this.setConfigValue(config, 'email.user',
|
|
197
|
-
this.setConfigValue(config, 'email.password',
|
|
198
|
-
this.setConfigValue(config, 'email.secure',
|
|
199
|
-
this.setConfigValue(config, 'email.from', process.env.SMTP_FROM, 'string')
|
|
200
|
-
|
|
201
|
-
// Storage configuration
|
|
202
|
-
this.setConfigValue(config, 'storage.uploadPath', process.env.UPLOAD_PATH, 'string')
|
|
203
|
-
this.setConfigValue(config, 'storage.maxFileSize', process.env.MAX_FILE_SIZE, 'number')
|
|
204
|
-
this.setConfigValue(config, 'storage.provider', process.env.STORAGE_PROVIDER, 'string')
|
|
205
|
-
|
|
206
|
-
// Plugin configuration
|
|
207
|
-
this.setConfigValue(config, 'plugins.enabled',
|
|
208
|
-
process.env.FLUXSTACK_PLUGINS_ENABLED, 'array')
|
|
209
|
-
this.setConfigValue(config, 'plugins.disabled',
|
|
210
|
-
process.env.FLUXSTACK_PLUGINS_DISABLED, 'array')
|
|
150
|
+
this.setConfigValue(config, 'email.host', env.SMTP_HOST, 'string')
|
|
151
|
+
this.setConfigValue(config, 'email.port', env.SMTP_PORT?.toString(), 'number')
|
|
152
|
+
this.setConfigValue(config, 'email.user', env.SMTP_USER, 'string')
|
|
153
|
+
this.setConfigValue(config, 'email.password', env.SMTP_PASSWORD, 'string')
|
|
154
|
+
this.setConfigValue(config, 'email.secure', env.SMTP_SECURE?.toString(), 'boolean')
|
|
211
155
|
|
|
212
156
|
return this.cleanEmptyObjects(config)
|
|
213
157
|
}
|