create-fluxstack 1.7.5 → 1.8.3

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.
Files changed (154) hide show
  1. package/.dockerignore +82 -0
  2. package/.env.example +19 -0
  3. package/Dockerfile +70 -0
  4. package/README.md +6 -3
  5. package/app/client/SIMPLIFICATION.md +140 -0
  6. package/app/client/frontend-only.ts +1 -1
  7. package/app/client/src/App.tsx +148 -283
  8. package/app/client/src/index.css +5 -20
  9. package/app/client/src/lib/eden-api.ts +53 -220
  10. package/app/client/src/main.tsx +2 -3
  11. package/app/server/app.ts +20 -5
  12. package/app/server/backend-only.ts +15 -12
  13. package/app/server/controllers/users.controller.ts +57 -31
  14. package/app/server/index.ts +86 -96
  15. package/app/server/live/register-components.ts +18 -7
  16. package/app/server/routes/env-test.ts +110 -0
  17. package/app/server/routes/index.ts +1 -8
  18. package/app/server/routes/users.routes.ts +192 -91
  19. package/config/app.config.ts +2 -54
  20. package/config/client.config.ts +95 -0
  21. package/config/fluxstack.config.ts +2 -2
  22. package/config/index.ts +57 -22
  23. package/config/monitoring.config.ts +114 -0
  24. package/config/plugins.config.ts +80 -0
  25. package/config/runtime.config.ts +0 -17
  26. package/config/server.config.ts +50 -30
  27. package/core/build/bundler.ts +17 -16
  28. package/core/build/flux-plugins-generator.ts +34 -23
  29. package/core/build/index.ts +32 -31
  30. package/core/build/live-components-generator.ts +44 -30
  31. package/core/build/optimizer.ts +37 -17
  32. package/core/cli/command-registry.ts +4 -14
  33. package/core/cli/commands/plugin-deps.ts +8 -8
  34. package/core/cli/generators/component.ts +3 -3
  35. package/core/cli/generators/controller.ts +4 -4
  36. package/core/cli/generators/index.ts +8 -8
  37. package/core/cli/generators/interactive.ts +4 -4
  38. package/core/cli/generators/plugin.ts +3 -3
  39. package/core/cli/generators/prompts.ts +1 -1
  40. package/core/cli/generators/route.ts +27 -11
  41. package/core/cli/generators/service.ts +5 -5
  42. package/core/cli/generators/template-engine.ts +1 -1
  43. package/core/cli/generators/types.ts +1 -1
  44. package/core/cli/index.ts +158 -189
  45. package/core/cli/plugin-discovery.ts +3 -3
  46. package/core/client/hooks/index.ts +2 -2
  47. package/core/client/hooks/state-validator.ts +1 -1
  48. package/core/client/hooks/useAuth.ts +1 -1
  49. package/core/client/hooks/useChunkedUpload.ts +1 -1
  50. package/core/client/hooks/useHybridLiveComponent.ts +1 -1
  51. package/core/client/hooks/useWebSocket.ts +1 -1
  52. package/core/config/env.ts +5 -1
  53. package/core/config/runtime-config.ts +12 -10
  54. package/core/config/schema.ts +33 -2
  55. package/core/framework/server.ts +30 -14
  56. package/core/framework/types.ts +2 -2
  57. package/core/index.ts +31 -23
  58. package/core/live/ComponentRegistry.ts +1 -1
  59. package/core/plugins/built-in/live-components/commands/create-live-component.ts +1 -1
  60. package/core/plugins/built-in/live-components/index.ts +1 -1
  61. package/core/plugins/built-in/monitoring/index.ts +65 -161
  62. package/core/plugins/built-in/static/index.ts +75 -277
  63. package/core/plugins/built-in/swagger/index.ts +301 -231
  64. package/core/plugins/built-in/vite/index.ts +342 -377
  65. package/core/plugins/config.ts +2 -2
  66. package/core/plugins/dependency-manager.ts +2 -2
  67. package/core/plugins/discovery.ts +1 -1
  68. package/core/plugins/executor.ts +2 -2
  69. package/core/plugins/manager.ts +19 -4
  70. package/core/plugins/module-resolver.ts +1 -1
  71. package/core/plugins/registry.ts +25 -21
  72. package/core/plugins/types.ts +147 -5
  73. package/core/server/backend-entry.ts +51 -0
  74. package/core/server/framework.ts +2 -2
  75. package/core/server/live/ComponentRegistry.ts +9 -26
  76. package/core/server/live/FileUploadManager.ts +1 -1
  77. package/core/server/live/auto-generated-components.ts +26 -0
  78. package/core/server/live/websocket-plugin.ts +211 -19
  79. package/core/server/middleware/errorHandling.ts +1 -1
  80. package/core/server/middleware/index.ts +4 -4
  81. package/core/server/plugins/database.ts +1 -2
  82. package/core/server/plugins/static-files-plugin.ts +259 -231
  83. package/core/server/plugins/swagger.ts +1 -1
  84. package/core/server/services/BaseService.ts +1 -1
  85. package/core/server/services/ServiceContainer.ts +1 -1
  86. package/core/server/services/index.ts +4 -4
  87. package/core/server/standalone.ts +16 -1
  88. package/core/testing/index.ts +1 -1
  89. package/core/testing/setup.ts +1 -1
  90. package/core/types/plugin.ts +6 -0
  91. package/core/utils/build-logger.ts +324 -0
  92. package/core/utils/config-schema.ts +2 -6
  93. package/core/utils/helpers.ts +14 -9
  94. package/core/utils/logger/startup-banner.ts +7 -33
  95. package/core/utils/regenerate-files.ts +69 -0
  96. package/core/utils/version.ts +6 -6
  97. package/create-fluxstack.ts +68 -25
  98. package/fluxstack.config.ts +138 -252
  99. package/package.json +3 -18
  100. package/plugins/crypto-auth/index.ts +52 -47
  101. package/plugins/crypto-auth/server/AuthMiddleware.ts +1 -1
  102. package/plugins/crypto-auth/server/middlewares/helpers.ts +16 -1
  103. package/vitest.config.ts +17 -26
  104. package/app/client/src/App.css +0 -883
  105. package/app/client/src/components/ErrorBoundary.tsx +0 -107
  106. package/app/client/src/components/ErrorDisplay.css +0 -365
  107. package/app/client/src/components/ErrorDisplay.tsx +0 -258
  108. package/app/client/src/components/FluxStackConfig.tsx +0 -1321
  109. package/app/client/src/components/HybridLiveCounter.tsx +0 -140
  110. package/app/client/src/components/LiveClock.tsx +0 -286
  111. package/app/client/src/components/MainLayout.tsx +0 -388
  112. package/app/client/src/components/SidebarNavigation.tsx +0 -391
  113. package/app/client/src/components/StateDemo.tsx +0 -178
  114. package/app/client/src/components/SystemMonitor.tsx +0 -1044
  115. package/app/client/src/components/UserProfile.tsx +0 -809
  116. package/app/client/src/hooks/useAuth.ts +0 -39
  117. package/app/client/src/hooks/useNotifications.ts +0 -56
  118. package/app/client/src/lib/errors.ts +0 -340
  119. package/app/client/src/lib/hooks/useErrorHandler.ts +0 -258
  120. package/app/client/src/lib/index.ts +0 -45
  121. package/app/client/src/pages/ApiDocs.tsx +0 -182
  122. package/app/client/src/pages/CryptoAuthPage.tsx +0 -394
  123. package/app/client/src/pages/Demo.tsx +0 -174
  124. package/app/client/src/pages/HybridLive.tsx +0 -263
  125. package/app/client/src/pages/Overview.tsx +0 -155
  126. package/app/client/src/store/README.md +0 -43
  127. package/app/client/src/store/index.ts +0 -16
  128. package/app/client/src/store/slices/uiSlice.ts +0 -151
  129. package/app/client/src/store/slices/userSlice.ts +0 -161
  130. package/app/client/src/test/README.md +0 -257
  131. package/app/client/src/test/setup.ts +0 -70
  132. package/app/client/src/test/types.ts +0 -12
  133. package/app/server/live/CounterComponent.ts +0 -191
  134. package/app/server/live/FluxStackConfig.ts +0 -534
  135. package/app/server/live/SidebarNavigation.ts +0 -157
  136. package/app/server/live/SystemMonitor.ts +0 -595
  137. package/app/server/live/SystemMonitorIntegration.ts +0 -151
  138. package/app/server/live/UserProfileComponent.ts +0 -141
  139. package/app/server/middleware/auth.ts +0 -136
  140. package/app/server/middleware/errorHandling.ts +0 -252
  141. package/app/server/middleware/index.ts +0 -10
  142. package/app/server/middleware/rateLimit.ts +0 -193
  143. package/app/server/middleware/requestLogging.ts +0 -215
  144. package/app/server/middleware/validation.ts +0 -270
  145. package/app/server/routes/config.ts +0 -145
  146. package/app/server/routes/crypto-auth-demo.routes.ts +0 -167
  147. package/app/server/routes/example-with-crypto-auth.routes.ts +0 -235
  148. package/app/server/routes/exemplo-posts.routes.ts +0 -161
  149. package/app/server/routes/upload.ts +0 -92
  150. package/app/server/services/NotificationService.ts +0 -302
  151. package/app/server/services/UserService.ts +0 -222
  152. package/app/server/services/index.ts +0 -46
  153. package/app/server/types/index.ts +0 -1
  154. package/config/build.config.ts +0 -24
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Application Configuration
3
- * Laravel-style declarative config with validation
3
+ * Core application metadata and global settings
4
4
  */
5
5
 
6
6
  import { defineConfig, config } from '@/core/utils/config-schema'
@@ -8,6 +8,7 @@ import { FLUXSTACK_VERSION } from '@/core/utils/version'
8
8
 
9
9
  /**
10
10
  * App configuration schema
11
+ * Contains only app-level metadata and global feature flags
11
12
  */
12
13
  const appConfigSchema = {
13
14
  // App basics
@@ -25,52 +26,9 @@ const appConfigSchema = {
25
26
  // Environment
26
27
  env: config.enum('NODE_ENV', ['development', 'production', 'test'] as const, 'development', true),
27
28
 
28
- debug: config.boolean('DEBUG', false),
29
-
30
- // Server
31
- port: {
32
- type: 'number' as const,
33
- env: 'PORT',
34
- default: 3000,
35
- required: true,
36
- validate: (value: number) => {
37
- if (value < 1 || value > 65535) {
38
- return 'Port must be between 1 and 65535'
39
- }
40
- return true
41
- }
42
- },
43
-
44
- host: config.string('HOST', 'localhost', true),
45
-
46
- apiPrefix: {
47
- type: 'string' as const,
48
- env: 'API_PREFIX',
49
- default: '/api',
50
- validate: (value: string) => value.startsWith('/') || 'API prefix must start with /'
51
- },
52
-
53
29
  // URLs
54
30
  url: config.string('APP_URL', undefined, false),
55
31
 
56
- // Features
57
- enableSwagger: config.boolean('ENABLE_SWAGGER', true),
58
- enableMetrics: config.boolean('ENABLE_METRICS', false),
59
- enableMonitoring: config.boolean('ENABLE_MONITORING', false),
60
-
61
- // Client
62
- clientPort: config.number('VITE_PORT', 5173),
63
-
64
- // Logging
65
- logLevel: config.enum('LOG_LEVEL', ['debug', 'info', 'warn', 'error'] as const, 'info'),
66
- logFormat: config.enum('LOG_FORMAT', ['json', 'pretty'] as const, 'pretty'),
67
-
68
- // CORS
69
- corsOrigins: config.array('CORS_ORIGINS', ['*']),
70
- corsMethods: config.array('CORS_METHODS', ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']),
71
- corsHeaders: config.array('CORS_HEADERS', ['Content-Type', 'Authorization']),
72
- corsCredentials: config.boolean('CORS_CREDENTIALS', false),
73
-
74
32
  // Security
75
33
  trustProxy: config.boolean('TRUST_PROXY', false),
76
34
 
@@ -100,15 +58,5 @@ export type AppConfig = typeof appConfig
100
58
  */
101
59
  export type Environment = typeof appConfig.env
102
60
 
103
- /**
104
- * Type-safe log level type
105
- */
106
- export type LogLevel = typeof appConfig.logLevel
107
-
108
- /**
109
- * Type-safe log format type
110
- */
111
- export type LogFormat = typeof appConfig.logFormat
112
-
113
61
  // Export default
114
62
  export default appConfig
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Client & Vite Configuration
3
+ * Declarative client, proxy and Vite dev server configuration
4
+ */
5
+
6
+ import { defineConfig, defineNestedConfig, config } from '@/core/utils/config-schema'
7
+ import { env, helpers } from '@/core/utils/env'
8
+
9
+ /**
10
+ * Vite Dev Server Configuration
11
+ */
12
+ const viteSchema = {
13
+ port: config.number('VITE_PORT', 5173, true),
14
+
15
+ host: config.string('VITE_HOST', 'localhost'),
16
+
17
+ strictPort: config.boolean('VITE_STRICT_PORT', false),
18
+
19
+ open: config.boolean('VITE_OPEN', false),
20
+
21
+ enableLogging: config.boolean('ENABLE_VITE_PROXY_LOGS', false)
22
+ } as const
23
+
24
+ /**
25
+ * API Proxy Configuration
26
+ */
27
+ const proxySchema = {
28
+ target: {
29
+ type: 'string' as const,
30
+ env: 'PROXY_TARGET',
31
+ default: helpers.getServerUrl(),
32
+ required: false,
33
+ validate: (value: string) => {
34
+ if (!value) return true
35
+ try {
36
+ new URL(value)
37
+ return true
38
+ } catch {
39
+ return 'Proxy target must be a valid URL'
40
+ }
41
+ }
42
+ },
43
+
44
+ changeOrigin: config.boolean('PROXY_CHANGE_ORIGIN', true),
45
+
46
+ secure: config.boolean('PROXY_SECURE', false),
47
+
48
+ ws: config.boolean('PROXY_WS', true), // WebSocket support
49
+
50
+ rewrite: {
51
+ type: 'object' as const,
52
+ env: 'PROXY_REWRITE',
53
+ default: {},
54
+ required: false
55
+ }
56
+ } as const
57
+
58
+ /**
59
+ * Client Build Configuration
60
+ */
61
+ const buildSchema = {
62
+ outDir: config.string('CLIENT_OUTDIR', 'dist/client'),
63
+
64
+ sourceMaps: config.boolean('CLIENT_SOURCEMAPS', helpers.isDevelopment()),
65
+
66
+ minify: config.boolean('CLIENT_MINIFY', helpers.isProduction()),
67
+
68
+ target: config.string('CLIENT_TARGET', 'esnext'),
69
+
70
+ assetsDir: config.string('CLIENT_ASSETS_DIR', 'assets'),
71
+
72
+ cssCodeSplit: config.boolean('CLIENT_CSS_CODE_SPLIT', true),
73
+
74
+ chunkSizeWarningLimit: config.number('CLIENT_CHUNK_SIZE_WARNING', 500), // KB
75
+
76
+ emptyOutDir: config.boolean('CLIENT_EMPTY_OUTDIR', true)
77
+ } as const
78
+
79
+ /**
80
+ * Client Configuration (nested)
81
+ */
82
+ export const clientConfig = defineNestedConfig({
83
+ vite: viteSchema,
84
+ proxy: proxySchema,
85
+ build: buildSchema
86
+ })
87
+
88
+ // Export types
89
+ export type ViteConfig = typeof clientConfig.vite
90
+ export type ProxyConfig = typeof clientConfig.proxy
91
+ export type ClientBuildConfig = typeof clientConfig.build
92
+ export type ClientConfig = typeof clientConfig
93
+
94
+ // Export default
95
+ export default clientConfig
@@ -4,8 +4,8 @@
4
4
  * @deprecated Use the configuration from the root fluxstack.config.ts instead
5
5
  */
6
6
 
7
- import { getConfigSync, createLegacyConfig } from '../core/config'
8
- import type { FluxStackConfig } from '../core/config'
7
+ import { getConfigSync, createLegacyConfig } from '@/core/config'
8
+ import type { FluxStackConfig } from '@/core/config'
9
9
 
10
10
  // Load the new configuration
11
11
  const newConfig = getConfigSync()
package/config/index.ts CHANGED
@@ -5,72 +5,107 @@
5
5
  *
6
6
  * @example
7
7
  * ```ts
8
- * import { appConfig, databaseConfig, servicesConfig } from '@/config'
8
+ * import { appConfig, serverConfig, databaseConfig } from '@/config'
9
9
  *
10
10
  * // All configs are type-safe and validated!
11
- * console.log(appConfig.name) // string
12
- * console.log(appConfig.port) // number
13
- * console.log(appConfig.debug) // boolean
11
+ * console.log(appConfig.name) // string
12
+ * console.log(serverConfig.server.port) // number
13
+ * console.log(clientConfig.vite.port) // number
14
14
  *
15
15
  * // Nested configs
16
- * console.log(servicesConfig.email.host) // string
17
- * console.log(servicesConfig.jwt.secret) // string
16
+ * console.log(servicesConfig.email.host) // string
17
+ * console.log(monitoringConfig.metrics.enabled) // boolean
18
18
  * ```
19
19
  */
20
20
 
21
+ // ============================================================================
22
+ // 📦 CONFIG EXPORTS
23
+ // ============================================================================
24
+
21
25
  export { appConfig } from './app.config'
26
+ export { serverConfig } from './server.config'
27
+ export { clientConfig } from './client.config'
22
28
  export { databaseConfig } from './database.config'
23
29
  export { servicesConfig } from './services.config'
24
- export { serverConfig } from './server.config'
25
30
  export { loggerConfig } from './logger.config'
26
- export { buildConfig } from './build.config'
31
+ export { pluginsConfig } from './plugins.config'
32
+ export { monitoringConfig } from './monitoring.config'
27
33
  export { appRuntimeConfig } from './runtime.config'
28
34
  export { systemConfig, systemRuntimeInfo } from './system.config'
29
35
 
30
36
  // Plugin configs (re-exported for convenience)
31
37
  export { cryptoAuthConfig } from '../plugins/crypto-auth/config'
32
38
 
33
- // Re-export types
34
- export type { AppConfig } from './app.config'
39
+ // ============================================================================
40
+ // 📝 TYPE EXPORTS
41
+ // ============================================================================
42
+
43
+ // Core types
44
+ export type { AppConfig, Environment } from './app.config'
45
+ export type {
46
+ ServerConfig,
47
+ CorsConfig,
48
+ ServerFullConfig
49
+ } from './server.config'
50
+ export type {
51
+ ClientConfig,
52
+ ViteConfig,
53
+ ProxyConfig,
54
+ ClientBuildConfig
55
+ } from './client.config'
35
56
  export type { DatabaseConfig } from './database.config'
36
- export type { ServerConfig } from './server.config'
37
- export type { LoggerConfig } from './logger.config'
38
- export type { BuildConfig } from './build.config'
39
- export type { SystemConfig, SystemRuntimeInfo } from './system.config'
40
57
  export type {
41
58
  EmailConfig,
42
59
  JWTConfig,
43
60
  StorageConfig,
44
61
  RedisConfig
45
62
  } from './services.config'
63
+ export type { LoggerConfig } from './logger.config'
64
+ export type { PluginsConfig } from './plugins.config'
65
+ export type {
66
+ MonitoringConfig,
67
+ MetricsConfig,
68
+ ProfilingConfig,
69
+ MonitoringFullConfig
70
+ } from './monitoring.config'
71
+ export type { SystemConfig, SystemRuntimeInfo } from './system.config'
46
72
 
47
73
  // Plugin types
48
74
  export type { CryptoAuthConfig } from '../plugins/crypto-auth/config'
49
75
 
50
- /**
51
- * All configs in one object
52
- */
76
+ // ============================================================================
77
+ // 🎯 UNIFIED CONFIG OBJECT
78
+ // ============================================================================
79
+
53
80
  import { appConfig } from './app.config'
81
+ import { serverConfig } from './server.config'
82
+ import { clientConfig } from './client.config'
54
83
  import { databaseConfig } from './database.config'
55
84
  import { servicesConfig } from './services.config'
56
- import { serverConfig } from './server.config'
57
85
  import { loggerConfig } from './logger.config'
58
- import { buildConfig } from './build.config'
86
+ import { pluginsConfig } from './plugins.config'
87
+ import { monitoringConfig } from './monitoring.config'
59
88
  import { appRuntimeConfig } from './runtime.config'
60
89
  import { systemConfig, systemRuntimeInfo } from './system.config'
61
90
  import { cryptoAuthConfig } from '../plugins/crypto-auth/config'
62
91
 
92
+ /**
93
+ * All configs in one object
94
+ * Use this when you need access to multiple configs at once
95
+ */
63
96
  export const config = {
64
97
  app: appConfig,
98
+ server: serverConfig,
99
+ client: clientConfig,
65
100
  database: databaseConfig,
66
101
  services: servicesConfig,
67
- server: serverConfig,
68
102
  logger: loggerConfig,
69
- build: buildConfig,
103
+ plugins: pluginsConfig,
104
+ monitoring: monitoringConfig,
70
105
  runtime: appRuntimeConfig,
71
106
  system: systemConfig,
72
107
  systemRuntime: systemRuntimeInfo,
73
108
  cryptoAuth: cryptoAuthConfig
74
- }
109
+ } as const
75
110
 
76
111
  export default config
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Monitoring Configuration
3
+ * Declarative monitoring, metrics and profiling configuration
4
+ */
5
+
6
+ import { defineConfig, defineNestedConfig, config } from '@/core/utils/config-schema'
7
+ import { helpers } from '@/core/utils/env'
8
+
9
+ /**
10
+ * Metrics Configuration Schema
11
+ */
12
+ const metricsSchema = {
13
+ enabled: config.boolean('ENABLE_METRICS', false),
14
+
15
+ collectInterval: {
16
+ type: 'number' as const,
17
+ env: 'METRICS_INTERVAL',
18
+ default: 5000,
19
+ validate: (value: number) => {
20
+ if (value < 1000) {
21
+ return 'Metrics interval must be at least 1000ms'
22
+ }
23
+ return true
24
+ }
25
+ },
26
+
27
+ httpMetrics: config.boolean('HTTP_METRICS', true),
28
+
29
+ systemMetrics: config.boolean('SYSTEM_METRICS', true),
30
+
31
+ customMetrics: config.boolean('CUSTOM_METRICS', false),
32
+
33
+ // Metric exporters
34
+ exportToConsole: config.boolean('METRICS_EXPORT_CONSOLE', helpers.isDevelopment()),
35
+
36
+ exportToFile: config.boolean('METRICS_EXPORT_FILE', false),
37
+
38
+ exportToHttp: config.boolean('METRICS_EXPORT_HTTP', false),
39
+
40
+ exportHttpUrl: config.string('METRICS_EXPORT_URL'),
41
+
42
+ // Metric storage
43
+ retentionPeriod: config.number('METRICS_RETENTION_PERIOD', 3600000), // 1 hour in ms
44
+
45
+ maxDataPoints: config.number('METRICS_MAX_DATA_POINTS', 1000)
46
+ } as const
47
+
48
+ /**
49
+ * Profiling Configuration Schema
50
+ */
51
+ const profilingSchema = {
52
+ enabled: config.boolean('PROFILING_ENABLED', false),
53
+
54
+ sampleRate: {
55
+ type: 'number' as const,
56
+ env: 'PROFILING_SAMPLE_RATE',
57
+ default: helpers.isProduction() ? 0.01 : 0.1,
58
+ validate: (value: number) => {
59
+ if (value < 0 || value > 1) {
60
+ return 'Sample rate must be between 0 and 1'
61
+ }
62
+ return true
63
+ }
64
+ },
65
+
66
+ memoryProfiling: config.boolean('MEMORY_PROFILING', false),
67
+
68
+ cpuProfiling: config.boolean('CPU_PROFILING', false),
69
+
70
+ heapSnapshot: config.boolean('HEAP_SNAPSHOT', false),
71
+
72
+ // Profiling output
73
+ outputDir: config.string('PROFILING_OUTPUT_DIR', 'profiling'),
74
+
75
+ maxProfiles: config.number('PROFILING_MAX_PROFILES', 10)
76
+ } as const
77
+
78
+ /**
79
+ * Monitoring Configuration Schema
80
+ */
81
+ const monitoringSchema = {
82
+ enabled: config.boolean('ENABLE_MONITORING', false),
83
+
84
+ // Exporters
85
+ exporters: config.array('MONITORING_EXPORTERS', []),
86
+
87
+ // Health checks
88
+ enableHealthChecks: config.boolean('ENABLE_HEALTH_CHECKS', true),
89
+
90
+ healthCheckInterval: config.number('HEALTH_CHECK_INTERVAL', 30000), // 30s
91
+
92
+ // Alerting
93
+ enableAlerts: config.boolean('ENABLE_ALERTS', false),
94
+
95
+ alertWebhook: config.string('ALERT_WEBHOOK')
96
+ } as const
97
+
98
+ /**
99
+ * Export monitoring config (nested)
100
+ */
101
+ export const monitoringConfig = defineNestedConfig({
102
+ monitoring: monitoringSchema,
103
+ metrics: metricsSchema,
104
+ profiling: profilingSchema
105
+ })
106
+
107
+ // Export types
108
+ export type MonitoringConfig = typeof monitoringConfig.monitoring
109
+ export type MetricsConfig = typeof monitoringConfig.metrics
110
+ export type ProfilingConfig = typeof monitoringConfig.profiling
111
+ export type MonitoringFullConfig = typeof monitoringConfig
112
+
113
+ // Export default
114
+ export default monitoringConfig
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Plugins Configuration
3
+ * Declarative plugin management configuration
4
+ */
5
+
6
+ import { defineConfig, config } from '@/core/utils/config-schema'
7
+ import { env } from '@/core/utils/env'
8
+ import { FLUXSTACK_VERSION } from '@/core/utils/version'
9
+
10
+ /**
11
+ * Plugins configuration schema
12
+ */
13
+ const pluginsConfigSchema = {
14
+ // Plugin management
15
+ enabled: config.array(
16
+ 'FLUXSTACK_PLUGINS_ENABLED',
17
+ ['logger', 'swagger', 'vite', 'cors', 'static-files', 'crypto-auth']
18
+ ),
19
+
20
+ disabled: config.array('FLUXSTACK_PLUGINS_DISABLED', []),
21
+
22
+ // Auto-discovery
23
+ autoDiscover: config.boolean('PLUGINS_AUTO_DISCOVER', true),
24
+
25
+ pluginsDir: config.string('PLUGINS_DIR', 'plugins'),
26
+
27
+ // Plugin-specific configurations
28
+ // Logger plugin (handled by logger.config.ts)
29
+ loggerEnabled: config.boolean('LOGGER_PLUGIN_ENABLED', true),
30
+
31
+ // Swagger plugin
32
+ swaggerEnabled: config.boolean('SWAGGER_ENABLED', true),
33
+ swaggerTitle: config.string('SWAGGER_TITLE', 'FluxStack API'),
34
+ swaggerVersion: config.string('SWAGGER_VERSION', FLUXSTACK_VERSION),
35
+ swaggerDescription: config.string(
36
+ 'SWAGGER_DESCRIPTION',
37
+ 'API documentation for FluxStack application'
38
+ ),
39
+ swaggerPath: config.string('SWAGGER_PATH', '/swagger'),
40
+
41
+ // Swagger advanced options
42
+ swaggerExcludePaths: config.array('SWAGGER_EXCLUDE_PATHS', []),
43
+
44
+ // Swagger servers (comma-separated list of URLs)
45
+ // Format: "url1|description1,url2|description2"
46
+ // Example: "https://api.prod.com|Production,https://api.staging.com|Staging"
47
+ swaggerServers: config.string('SWAGGER_SERVERS', ''),
48
+
49
+ // Swagger UI options
50
+ swaggerPersistAuthorization: config.boolean('SWAGGER_PERSIST_AUTH', true),
51
+ swaggerDisplayRequestDuration: config.boolean('SWAGGER_DISPLAY_DURATION', true),
52
+ swaggerEnableFilter: config.boolean('SWAGGER_ENABLE_FILTER', true),
53
+ swaggerShowExtensions: config.boolean('SWAGGER_SHOW_EXTENSIONS', true),
54
+ swaggerTryItOutEnabled: config.boolean('SWAGGER_TRY_IT_OUT', true),
55
+
56
+ // Swagger authentication (Basic Auth)
57
+ swaggerAuthEnabled: config.boolean('SWAGGER_AUTH_ENABLED', false),
58
+ swaggerAuthUsername: config.string('SWAGGER_AUTH_USERNAME', 'admin'),
59
+ swaggerAuthPassword: config.string('SWAGGER_AUTH_PASSWORD', ''),
60
+
61
+ // Static files plugin
62
+ staticFilesEnabled: config.boolean('STATIC_FILES_ENABLED', true),
63
+ staticPublicDir: config.string('STATIC_PUBLIC_DIR', 'public'),
64
+ staticUploadsDir: config.string('STATIC_UPLOADS_DIR', 'uploads'),
65
+ staticCacheMaxAge: config.number('STATIC_CACHE_MAX_AGE', 31536000), // 1 year
66
+ staticEnableUploads: config.boolean('STATIC_ENABLE_UPLOADS', true),
67
+ staticEnablePublic: config.boolean('STATIC_ENABLE_PUBLIC', true),
68
+
69
+ // CORS plugin (configuration via server.config.ts)
70
+ // Vite plugin
71
+ viteEnabled: config.boolean('VITE_PLUGIN_ENABLED', true)
72
+ } as const
73
+
74
+ export const pluginsConfig = defineConfig(pluginsConfigSchema)
75
+
76
+ // Export type
77
+ export type PluginsConfig = typeof pluginsConfig
78
+
79
+ // Export default
80
+ export default pluginsConfig
@@ -16,19 +16,6 @@ export const appRuntimeConfig = defineReactiveConfig({
16
16
  enableMonitoring: config.boolean('ENABLE_MONITORING', false),
17
17
  enableDebugMode: config.boolean('DEBUG', false),
18
18
 
19
- // Logging level can be changed in runtime
20
- logLevel: config.enum(
21
- 'LOG_LEVEL',
22
- ['debug', 'info', 'warn', 'error'] as const,
23
- 'info'
24
- ),
25
-
26
- logFormat: config.enum(
27
- 'LOG_FORMAT',
28
- ['json', 'pretty'] as const,
29
- 'pretty'
30
- ),
31
-
32
19
  // Rate limiting
33
20
  rateLimitEnabled: config.boolean('RATE_LIMIT_ENABLED', true),
34
21
 
@@ -62,9 +49,6 @@ export const appRuntimeConfig = defineReactiveConfig({
62
49
  validate: (value: number) => value > 0 || 'Max upload size must be positive'
63
50
  },
64
51
 
65
- // Allowed origins (can be updated in runtime)
66
- corsOrigins: config.array('CORS_ORIGINS', ['*']),
67
-
68
52
  // Maintenance mode
69
53
  maintenanceMode: config.boolean('MAINTENANCE_MODE', false),
70
54
 
@@ -80,7 +64,6 @@ export const appRuntimeConfig = defineReactiveConfig({
80
64
  appRuntimeConfig.watch((newConfig) => {
81
65
  console.log('🔄 Runtime config reloaded:')
82
66
  console.log(' Debug:', newConfig.enableDebugMode)
83
- console.log(' Log Level:', newConfig.logLevel)
84
67
  console.log(' Maintenance:', newConfig.maintenanceMode)
85
68
  })
86
69
 
@@ -1,48 +1,68 @@
1
1
  /**
2
2
  * Server Configuration
3
- * Declarative server config using FluxStack config system
3
+ * Server-specific settings (port, host, CORS, middleware)
4
4
  */
5
5
 
6
- import { defineConfig, config } from '@/core/utils/config-schema'
7
- import { FLUXSTACK_VERSION } from '@/core/utils/version'
6
+ import { defineConfig, defineNestedConfig, config } from '@/core/utils/config-schema'
8
7
 
9
- const serverConfigSchema = {
8
+ /**
9
+ * CORS configuration schema
10
+ */
11
+ const corsSchema = {
12
+ origins: config.array('CORS_ORIGINS', ['http://localhost:3000', 'http://localhost:5173']),
13
+ methods: config.array('CORS_METHODS', ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']),
14
+ headers: config.array('CORS_HEADERS', ['Content-Type', 'Authorization']),
15
+ credentials: config.boolean('CORS_CREDENTIALS', false),
16
+ maxAge: config.number('CORS_MAX_AGE', 86400)
17
+ } as const
18
+
19
+ /**
20
+ * Server configuration schema
21
+ */
22
+ const serverSchema = {
10
23
  // Server basics
11
- port: config.number('PORT', 3000, true),
12
- host: config.string('HOST', 'localhost', true),
13
- apiPrefix: config.string('API_PREFIX', '/api'),
24
+ port: {
25
+ type: 'number' as const,
26
+ env: 'PORT',
27
+ default: 3000,
28
+ required: true,
29
+ validate: (value: number) => {
30
+ if (value < 1 || value > 65535) {
31
+ return 'Port must be between 1 and 65535'
32
+ }
33
+ return true
34
+ }
35
+ },
14
36
 
15
- // CORS configuration
16
- corsOrigins: config.array('CORS_ORIGINS', ['http://localhost:3000', 'http://localhost:5173']),
17
- corsMethods: config.array('CORS_METHODS', ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']),
18
- corsHeaders: config.array('CORS_HEADERS', ['Content-Type', 'Authorization']),
19
- corsCredentials: config.boolean('CORS_CREDENTIALS', false),
20
- corsMaxAge: config.number('CORS_MAX_AGE', 86400),
37
+ host: config.string('HOST', 'localhost', true),
21
38
 
22
- // Client config
23
- clientPort: config.number('VITE_PORT', 5173),
24
- clientTarget: config.string('CLIENT_TARGET', 'es2020'),
25
- clientOutDir: config.string('CLIENT_OUTDIR', 'dist'),
26
- clientSourceMaps: config.boolean('CLIENT_SOURCEMAPS', false),
39
+ apiPrefix: {
40
+ type: 'string' as const,
41
+ env: 'API_PREFIX',
42
+ default: '/api',
43
+ validate: (value: string) => value.startsWith('/') || 'API prefix must start with /'
44
+ },
27
45
 
28
46
  // Backend-only mode
29
47
  backendPort: config.number('BACKEND_PORT', 3001),
30
48
 
31
- // App info
32
- appName: config.string('FLUXSTACK_APP_NAME', 'FluxStack'),
33
- appVersion: config.string('FLUXSTACK_APP_VERSION', FLUXSTACK_VERSION),
34
-
35
49
  // Features
36
- enableSwagger: config.boolean('ENABLE_SWAGGER', true),
37
- enableMetrics: config.boolean('ENABLE_METRICS', false),
38
- enableMonitoring: config.boolean('ENABLE_MONITORING', false),
39
50
  enableRequestLogging: config.boolean('ENABLE_REQUEST_LOGGING', true),
40
-
41
- // Vite/Development
42
- enableViteProxyLogs: config.boolean('ENABLE_VITE_PROXY_LOGS', false)
51
+ showBanner: config.boolean('SHOW_SERVER_BANNER', true)
43
52
  } as const
44
53
 
45
- export const serverConfig = defineConfig(serverConfigSchema)
54
+ /**
55
+ * Export server config (nested with CORS)
56
+ */
57
+ export const serverConfig = defineNestedConfig({
58
+ server: serverSchema,
59
+ cors: corsSchema
60
+ })
61
+
62
+ // Export types
63
+ export type ServerConfig = typeof serverConfig.server
64
+ export type CorsConfig = typeof serverConfig.cors
65
+ export type ServerFullConfig = typeof serverConfig
46
66
 
47
- export type ServerConfig = typeof serverConfig
67
+ // Export default
48
68
  export default serverConfig