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,274 +1,106 @@
1
1
  /**
2
2
  * FluxStack Configuration
3
- * ✅ Using declarative config system with schema validation and type inference
4
- * Laravel-inspired declarative configuration with full type safety
3
+ * ✅ Refactored to use modular config system from /config
4
+ *
5
+ * This file composes configs from /config into the FluxStackConfig format
6
+ * required by core/config/schema.ts for backward compatibility
5
7
  */
6
8
 
7
9
  import type { FluxStackConfig } from './core/config/schema'
8
- import { defineConfig, config as configHelpers } from './core/utils/config-schema'
9
10
  import { env, helpers } from './core/utils/env'
10
- import { FLUXSTACK_VERSION } from './core/utils/version'
11
11
 
12
- console.log(`🔧 Loading FluxStack config for ${env.NODE_ENV} environment`)
12
+ // Import modular configs
13
+ import { appConfig } from './config/app.config'
14
+ import { serverConfig } from './config/server.config'
15
+ import { clientConfig } from './config/client.config'
16
+ import { databaseConfig } from './config/database.config'
17
+ import { servicesConfig } from './config/services.config'
18
+ import { loggerConfig } from './config/logger.config'
19
+ import { pluginsConfig } from './config/plugins.config'
20
+ import { monitoringConfig } from './config/monitoring.config'
13
21
 
14
- // ============================================================================
15
- // 📋 DECLARATIVE CONFIG SCHEMAS
16
- // ============================================================================
17
-
18
- /**
19
- * Application Configuration Schema
20
- */
21
- const appConfigSchema = {
22
- name: configHelpers.string('FLUXSTACK_APP_NAME', 'FluxStack', true),
23
- version: configHelpers.string('FLUXSTACK_APP_VERSION', FLUXSTACK_VERSION, true),
24
- description: configHelpers.string('FLUXSTACK_APP_DESCRIPTION', 'A FluxStack application')
25
- } as const
26
-
27
- /**
28
- * CORS Configuration Schema
29
- */
30
- const corsConfigSchema = {
31
- origins: configHelpers.array('CORS_ORIGINS', ['http://localhost:3000', 'http://localhost:5173']),
32
- methods: configHelpers.array('CORS_METHODS', ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']),
33
- headers: configHelpers.array('CORS_HEADERS', ['Content-Type', 'Authorization']),
34
- credentials: configHelpers.boolean('CORS_CREDENTIALS', false),
35
- maxAge: configHelpers.number('CORS_MAX_AGE', 86400)
36
- } as const
37
-
38
- /**
39
- * Server Configuration Schema
40
- */
41
- const serverConfigSchema = {
42
- port: configHelpers.number('PORT', 3000, true),
43
- host: configHelpers.string('HOST', 'localhost', true),
44
- apiPrefix: configHelpers.string('API_PREFIX', '/api', true)
45
- } as const
46
-
47
- /**
48
- * Client Proxy Configuration Schema
49
- */
50
- const clientProxyConfigSchema = {
51
- target: {
52
- type: 'string' as const,
53
- env: 'PROXY_TARGET',
54
- default: helpers.getServerUrl(),
55
- required: false
56
- },
57
- changeOrigin: configHelpers.boolean('PROXY_CHANGE_ORIGIN', true)
58
- } as const
59
-
60
- /**
61
- * Client Build Configuration Schema
62
- */
63
- const clientBuildConfigSchema = {
64
- sourceMaps: configHelpers.boolean('CLIENT_SOURCEMAPS', helpers.isDevelopment()),
65
- minify: configHelpers.boolean('CLIENT_MINIFY', helpers.isProduction()),
66
- target: configHelpers.string('CLIENT_TARGET', 'esnext'),
67
- outDir: configHelpers.string('CLIENT_OUTDIR', 'dist/client')
68
- } as const
69
-
70
- /**
71
- * Client Configuration Schema
72
- */
73
- const clientConfigSchema = {
74
- port: configHelpers.number('VITE_PORT', 5173, true)
75
- } as const
76
-
77
- /**
78
- * Build Optimization Configuration Schema
79
- */
80
- const buildOptimizationConfigSchema = {
81
- minify: configHelpers.boolean('BUILD_MINIFY', helpers.isProduction()),
82
- treeshake: configHelpers.boolean('BUILD_TREESHAKE', helpers.isProduction()),
83
- compress: configHelpers.boolean('BUILD_COMPRESS', helpers.isProduction()),
84
- splitChunks: configHelpers.boolean('BUILD_SPLIT_CHUNKS', true),
85
- bundleAnalyzer: configHelpers.boolean('BUILD_ANALYZER', helpers.isDevelopment())
86
- } as const
87
-
88
- /**
89
- * Build Configuration Schema
90
- */
91
- const buildConfigSchema = {
92
- target: configHelpers.enum('BUILD_TARGET', ['bun', 'node', 'docker'] as const, 'bun'),
93
- outDir: configHelpers.string('BUILD_OUTDIR', 'dist'),
94
- sourceMaps: configHelpers.boolean('BUILD_SOURCEMAPS', !helpers.isProduction()),
95
- minify: configHelpers.boolean('BUILD_MINIFY', helpers.isProduction()),
96
- treeshake: configHelpers.boolean('BUILD_TREESHAKE', helpers.isProduction()),
97
- clean: configHelpers.boolean('BUILD_CLEAN', true)
98
- } as const
99
-
100
- /**
101
- * Plugins Configuration Schema
102
- */
103
- const pluginsConfigSchema = {
104
- enabled: configHelpers.array('FLUXSTACK_PLUGINS_ENABLED', ['logger', 'swagger', 'vite', 'cors', 'static-files', 'crypto-auth']),
105
- disabled: configHelpers.array('FLUXSTACK_PLUGINS_DISABLED', [])
106
- } as const
107
-
108
- /**
109
- * Logging Configuration Schema
110
- */
111
- const loggingConfigSchema = {
112
- level: configHelpers.enum('LOG_LEVEL', ['debug', 'info', 'warn', 'error'] as const, helpers.isDevelopment() ? 'debug' : 'info'),
113
- format: configHelpers.enum('LOG_FORMAT', ['json', 'pretty'] as const, helpers.isDevelopment() ? 'pretty' : 'json')
114
- } as const
115
-
116
- /**
117
- * Monitoring Metrics Configuration Schema
118
- */
119
- const monitoringMetricsConfigSchema = {
120
- enabled: configHelpers.boolean('ENABLE_METRICS', false),
121
- collectInterval: configHelpers.number('METRICS_INTERVAL', 5000),
122
- httpMetrics: configHelpers.boolean('HTTP_METRICS', true),
123
- systemMetrics: configHelpers.boolean('SYSTEM_METRICS', true),
124
- customMetrics: configHelpers.boolean('CUSTOM_METRICS', false)
125
- } as const
126
-
127
- /**
128
- * Monitoring Profiling Configuration Schema
129
- */
130
- const monitoringProfilingConfigSchema = {
131
- enabled: configHelpers.boolean('PROFILING_ENABLED', false),
132
- sampleRate: configHelpers.number('PROFILING_SAMPLE_RATE', 0.1),
133
- memoryProfiling: configHelpers.boolean('MEMORY_PROFILING', false),
134
- cpuProfiling: configHelpers.boolean('CPU_PROFILING', false)
135
- } as const
136
-
137
- /**
138
- * Monitoring Configuration Schema
139
- */
140
- const monitoringConfigSchema = {
141
- enabled: configHelpers.boolean('ENABLE_MONITORING', false),
142
- exporters: configHelpers.array('MONITORING_EXPORTERS', [])
143
- } as const
144
-
145
- /**
146
- * Database Configuration Schema (Optional)
147
- */
148
- const databaseConfigSchema = {
149
- url: configHelpers.string('DATABASE_URL', ''),
150
- host: configHelpers.string('DB_HOST', ''),
151
- port: configHelpers.number('DB_PORT', 5432),
152
- database: configHelpers.string('DB_NAME', ''),
153
- user: configHelpers.string('DB_USER', ''),
154
- password: configHelpers.string('DB_PASSWORD', ''),
155
- ssl: configHelpers.boolean('DB_SSL', false),
156
- poolSize: configHelpers.number('DB_POOL_SIZE', 10)
157
- } as const
158
-
159
- /**
160
- * Auth Configuration Schema (Optional)
161
- */
162
- const authConfigSchema = {
163
- secret: configHelpers.string('JWT_SECRET', ''),
164
- expiresIn: configHelpers.string('JWT_EXPIRES_IN', '24h'),
165
- algorithm: configHelpers.string('JWT_ALGORITHM', 'HS256'),
166
- issuer: configHelpers.string('JWT_ISSUER', '')
167
- } as const
168
-
169
- /**
170
- * Email Configuration Schema (Optional)
171
- */
172
- const emailConfigSchema = {
173
- host: configHelpers.string('SMTP_HOST', ''),
174
- port: configHelpers.number('SMTP_PORT', 587),
175
- user: configHelpers.string('SMTP_USER', ''),
176
- password: configHelpers.string('SMTP_PASSWORD', ''),
177
- secure: configHelpers.boolean('SMTP_SECURE', false),
178
- from: configHelpers.string('SMTP_FROM', '')
179
- } as const
180
-
181
- /**
182
- * Storage Configuration Schema (Optional)
183
- */
184
- const storageConfigSchema = {
185
- uploadPath: configHelpers.string('UPLOAD_PATH', ''),
186
- maxFileSize: configHelpers.number('MAX_FILE_SIZE', 10485760), // 10MB
187
- allowedTypes: configHelpers.array('ALLOWED_FILE_TYPES', []),
188
- provider: configHelpers.enum('STORAGE_PROVIDER', ['local', 's3', 'gcs'] as const, 'local')
189
- } as const
22
+ console.log(`🔧 Loading FluxStack config for ${appConfig.env} environment`)
190
23
 
191
24
  // ============================================================================
192
- // LOAD CONFIGURATIONS USING DECLARATIVE SYSTEM
193
- // ============================================================================
194
-
195
- const appConfig = defineConfig(appConfigSchema)
196
- const corsConfig = defineConfig(corsConfigSchema)
197
- const serverConfig = defineConfig(serverConfigSchema)
198
- const clientProxyConfig = defineConfig(clientProxyConfigSchema)
199
- const clientBuildConfig = defineConfig(clientBuildConfigSchema)
200
- const clientConfig = defineConfig(clientConfigSchema)
201
- const buildOptimizationConfig = defineConfig(buildOptimizationConfigSchema)
202
- const buildConfig = defineConfig(buildConfigSchema)
203
- const pluginsConfig = defineConfig(pluginsConfigSchema)
204
- const loggingConfig = defineConfig(loggingConfigSchema)
205
- const monitoringMetricsConfig = defineConfig(monitoringMetricsConfigSchema)
206
- const monitoringProfilingConfig = defineConfig(monitoringProfilingConfigSchema)
207
- const monitoringConfig = defineConfig(monitoringConfigSchema)
208
-
209
- // Optional configs (only load if env vars are present)
210
- const databaseConfig = (env.has('DATABASE_URL') || env.has('DATABASE_HOST'))
211
- ? defineConfig(databaseConfigSchema)
212
- : undefined
213
-
214
- const authConfig = env.has('JWT_SECRET')
215
- ? defineConfig(authConfigSchema)
216
- : undefined
217
-
218
- const emailConfig = env.has('SMTP_HOST')
219
- ? defineConfig(emailConfigSchema)
220
- : undefined
221
-
222
- const storageConfig = (env.has('UPLOAD_PATH') || env.has('STORAGE_PROVIDER'))
223
- ? defineConfig(storageConfigSchema)
224
- : undefined
225
-
226
- // ============================================================================
227
- // 🚀 MAIN FLUXSTACK CONFIGURATION
25
+ // 🚀 MAIN FLUXSTACK CONFIGURATION (Composed from /config)
228
26
  // ============================================================================
229
27
 
230
28
  export const config: FluxStackConfig = {
231
29
  // Application metadata
232
- app: appConfig,
30
+ app: {
31
+ name: appConfig.name,
32
+ version: appConfig.version,
33
+ description: appConfig.description
34
+ },
233
35
 
234
36
  // Server configuration
235
37
  server: {
236
- ...serverConfig,
237
- cors: corsConfig,
238
- middleware: []
38
+ port: serverConfig.server.port,
39
+ host: serverConfig.server.host,
40
+ apiPrefix: serverConfig.server.apiPrefix,
41
+ cors: {
42
+ origins: serverConfig.cors.origins,
43
+ methods: serverConfig.cors.methods,
44
+ headers: serverConfig.cors.headers,
45
+ credentials: serverConfig.cors.credentials,
46
+ maxAge: serverConfig.cors.maxAge
47
+ },
48
+ middleware: [],
49
+ showBanner: serverConfig.server.showBanner
239
50
  },
240
51
 
241
52
  // Client configuration
242
53
  client: {
243
- ...clientConfig,
244
- proxy: clientProxyConfig,
245
- build: clientBuildConfig
54
+ port: clientConfig.vite.port,
55
+ proxy: {
56
+ target: clientConfig.proxy.target || helpers.getServerUrl(),
57
+ changeOrigin: clientConfig.proxy.changeOrigin
58
+ },
59
+ build: {
60
+ sourceMaps: clientConfig.build.sourceMaps,
61
+ minify: clientConfig.build.minify,
62
+ target: clientConfig.build.target,
63
+ outDir: clientConfig.build.outDir
64
+ }
246
65
  },
247
66
 
248
67
  // Build configuration
249
68
  build: {
250
- ...buildConfig,
251
- optimization: buildOptimizationConfig
69
+ target: 'bun',
70
+ mode: appConfig.env as 'development' | 'production' | 'test',
71
+ outDir: 'dist',
72
+ optimization: {
73
+ minify: helpers.isProduction(),
74
+ treeshake: helpers.isProduction(),
75
+ compress: helpers.isProduction(),
76
+ splitChunks: true,
77
+ bundleAnalyzer: helpers.isDevelopment()
78
+ },
79
+ sourceMaps: !helpers.isProduction(),
80
+ minify: helpers.isProduction(),
81
+ treeshake: helpers.isProduction(),
82
+ clean: true
252
83
  },
253
84
 
254
85
  // Plugin configuration
255
86
  plugins: {
256
- ...pluginsConfig,
87
+ enabled: pluginsConfig.enabled,
88
+ disabled: pluginsConfig.disabled,
257
89
  config: {
258
90
  logger: {
259
91
  // Logger plugin config handled by logging section
260
92
  },
261
93
  swagger: {
262
- title: env.get('SWAGGER_TITLE', 'FluxStack API'),
263
- version: env.get('SWAGGER_VERSION', FLUXSTACK_VERSION),
264
- description: env.get('SWAGGER_DESCRIPTION', 'API documentation for FluxStack application')
94
+ title: pluginsConfig.swaggerTitle,
95
+ version: pluginsConfig.swaggerVersion,
96
+ description: pluginsConfig.swaggerDescription
265
97
  },
266
98
  staticFiles: {
267
- publicDir: env.get('STATIC_PUBLIC_DIR', 'public'),
268
- uploadsDir: env.get('STATIC_UPLOADS_DIR', 'uploads'),
269
- cacheMaxAge: env.get('STATIC_CACHE_MAX_AGE', 31536000), // 1 year
270
- enableUploads: env.get('STATIC_ENABLE_UPLOADS', true),
271
- enablePublic: env.get('STATIC_ENABLE_PUBLIC', true)
99
+ publicDir: pluginsConfig.staticPublicDir,
100
+ uploadsDir: pluginsConfig.staticUploadsDir,
101
+ cacheMaxAge: pluginsConfig.staticCacheMaxAge,
102
+ enableUploads: pluginsConfig.staticEnableUploads,
103
+ enablePublic: pluginsConfig.staticEnablePublic
272
104
  }
273
105
  // ✅ crypto-auth manages its own configuration
274
106
  // See: plugins/crypto-auth/config/index.ts
@@ -277,33 +109,87 @@ export const config: FluxStackConfig = {
277
109
 
278
110
  // Logging configuration
279
111
  logging: {
280
- ...loggingConfig,
112
+ level: loggerConfig.level,
113
+ format: helpers.isDevelopment() ? 'pretty' : 'json',
281
114
  transports: [
282
115
  {
283
116
  type: 'console' as const,
284
- level: loggingConfig.level,
285
- format: loggingConfig.format
117
+ level: loggerConfig.level,
118
+ format: helpers.isDevelopment() ? 'pretty' : 'json'
286
119
  }
287
120
  ]
288
121
  },
289
122
 
290
123
  // Monitoring configuration
291
124
  monitoring: {
292
- ...monitoringConfig,
293
- metrics: monitoringMetricsConfig,
294
- profiling: monitoringProfilingConfig
125
+ enabled: monitoringConfig.monitoring.enabled,
126
+ metrics: {
127
+ enabled: monitoringConfig.metrics.enabled,
128
+ collectInterval: monitoringConfig.metrics.collectInterval,
129
+ httpMetrics: monitoringConfig.metrics.httpMetrics,
130
+ systemMetrics: monitoringConfig.metrics.systemMetrics,
131
+ customMetrics: monitoringConfig.metrics.customMetrics
132
+ },
133
+ profiling: {
134
+ enabled: monitoringConfig.profiling.enabled,
135
+ sampleRate: monitoringConfig.profiling.sampleRate,
136
+ memoryProfiling: monitoringConfig.profiling.memoryProfiling,
137
+ cpuProfiling: monitoringConfig.profiling.cpuProfiling
138
+ },
139
+ exporters: monitoringConfig.monitoring.exporters
295
140
  },
296
141
 
297
- // Optional configurations (only included if env vars are set)
298
- ...(databaseConfig ? { database: databaseConfig } : {}),
299
- ...(authConfig ? { auth: authConfig } : {}),
300
- ...(emailConfig ? { email: emailConfig } : {}),
301
- ...(storageConfig ? {
302
- storage: {
303
- ...storageConfig,
304
- config: env.get('STORAGE_CONFIG', {})
305
- }
306
- } : {}),
142
+ // Optional configurations (only included if configured)
143
+ ...(databaseConfig.url || databaseConfig.host
144
+ ? {
145
+ database: {
146
+ url: databaseConfig.url,
147
+ host: databaseConfig.host,
148
+ port: databaseConfig.port,
149
+ database: databaseConfig.database,
150
+ user: databaseConfig.user,
151
+ password: databaseConfig.password,
152
+ ssl: databaseConfig.ssl,
153
+ poolSize: databaseConfig.poolMax
154
+ }
155
+ }
156
+ : {}),
157
+
158
+ ...(servicesConfig.jwt.secret
159
+ ? {
160
+ auth: {
161
+ secret: servicesConfig.jwt.secret,
162
+ expiresIn: servicesConfig.jwt.expiresIn,
163
+ algorithm: servicesConfig.jwt.algorithm,
164
+ issuer: servicesConfig.jwt.issuer
165
+ }
166
+ }
167
+ : {}),
168
+
169
+ ...(servicesConfig.email.host
170
+ ? {
171
+ email: {
172
+ host: servicesConfig.email.host,
173
+ port: servicesConfig.email.port,
174
+ user: servicesConfig.email.user,
175
+ password: servicesConfig.email.password,
176
+ secure: servicesConfig.email.secure,
177
+ from: servicesConfig.email.from
178
+ }
179
+ }
180
+ : {}),
181
+
182
+ ...(servicesConfig.storage.uploadPath
183
+ ? {
184
+ storage: {
185
+ uploadPath: servicesConfig.storage.uploadPath,
186
+ maxFileSize: servicesConfig.storage.maxFileSize,
187
+ allowedTypes: servicesConfig.storage.allowedTypes,
188
+ provider: servicesConfig.storage.provider,
189
+ config: {}
190
+ }
191
+ }
192
+ : {}),
307
193
 
308
194
  // Environment-specific overrides
309
195
  environments: {
@@ -465,4 +351,4 @@ export default config
465
351
  export { config as fluxStackConfig }
466
352
 
467
353
  // Export type for TypeScript users
468
- export type { FluxStackConfig } from './core/config/schema'
354
+ export type { FluxStackConfig } from './core/config/schema'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fluxstack",
3
- "version": "1.7.5",
3
+ "version": "1.8.3",
4
4
  "description": "⚡ Revolutionary full-stack TypeScript framework with Declarative Config System, Elysia + React + Bun",
5
5
  "keywords": [
6
6
  "framework",
@@ -27,35 +27,20 @@
27
27
  "dev": "bun run core/cli/index.ts dev",
28
28
  "dev:frontend": "bun run core/cli/index.ts frontend",
29
29
  "dev:backend": "bun run core/cli/index.ts backend",
30
- "dev:coordinated": "concurrently --prefix {name} --names BACKEND,VITE --prefix-colors blue,green --kill-others-on-fail \"bun --watch app/server/index.ts\" \"vite --config vite.config.ts\"",
31
30
  "sync-version": "bun run core/utils/sync-version.ts",
32
31
  "build": "cross-env NODE_ENV=production bun run core/cli/index.ts build",
33
- "build:frontend": "vite build --config vite.config.ts --emptyOutDir",
32
+ "build:frontend": "bun run core/cli/index.ts build:frontend",
34
33
  "build:backend": "bun run core/cli/index.ts build:backend",
35
34
  "start": "bun run core/cli/index.ts start",
36
35
  "start:frontend": "bun run app/client/frontend-only.ts",
37
36
  "start:backend": "bun run app/server/backend-only.ts",
38
- "docker:build": "cd dist && docker build -t fluxstack-app .",
39
- "docker:run": "cd dist && docker run -p 3000:3000 fluxstack-app",
40
- "docker:compose": "cd dist && docker-compose up -d",
41
- "docker:stop": "cd dist && docker-compose down",
42
37
  "create": "bun run core/cli/index.ts create",
43
38
  "cli": "bun run core/cli/index.ts",
44
39
  "make:component": "bun run core/cli/index.ts make:component",
45
40
  "make:live": "bun run core/cli/index.ts make:component",
46
41
  "test": "vitest",
47
42
  "test:ui": "vitest --ui",
48
- "test:run": "vitest run",
49
- "test:coverage": "vitest run --coverage",
50
- "test:watch": "vitest --watch",
51
- "test:live": "tsx scripts/test-live-components.ts",
52
- "test:live:coverage": "tsx scripts/test-live-components.ts --coverage",
53
- "test:live:watch": "tsx scripts/test-live-components.ts --watch",
54
- "test:live:verbose": "tsx scripts/test-live-components.ts --verbose",
55
- "test:config": "bun run core/config/__tests__/run-tests.ts",
56
- "test:config:coverage": "bun run core/config/__tests__/run-tests.ts coverage",
57
- "test:config:manual": "bun run core/config/__tests__/manual-test.ts",
58
- "legacy:dev": "bun --watch app/server/index.ts"
43
+ "test:coverage": "vitest run --coverage"
59
44
  },
60
45
  "devDependencies": {
61
46
  "@eslint/js": "^9.30.1",
@@ -3,7 +3,7 @@
3
3
  * Sistema de autenticação baseado em criptografia Ed25519
4
4
  */
5
5
 
6
- import type { FluxStack, PluginContext, RequestContext, ResponseContext } from "../../core/plugins/types"
6
+ import type { FluxStack, PluginContext, RequestContext, ResponseContext } from "@/core/plugins/types"
7
7
 
8
8
  type Plugin = FluxStack.Plugin
9
9
  import { Elysia, t } from "elysia"
@@ -13,6 +13,36 @@ import { makeProtectedRouteCommand } from "./cli/make-protected-route.command"
13
13
  // ✅ Plugin carrega sua própria configuração (da pasta config/ do plugin)
14
14
  import { cryptoAuthConfig } from "./config"
15
15
 
16
+ // Response schema for auth info endpoint
17
+ const AuthInfoResponseSchema = t.Object({
18
+ name: t.String(),
19
+ description: t.String(),
20
+ version: t.String(),
21
+ mode: t.String(),
22
+ how_it_works: t.Object({
23
+ step1: t.String(),
24
+ step2: t.String(),
25
+ step3: t.String(),
26
+ step4: t.String(),
27
+ step5: t.String()
28
+ }),
29
+ required_headers: t.Object({
30
+ "x-public-key": t.String(),
31
+ "x-timestamp": t.String(),
32
+ "x-nonce": t.String(),
33
+ "x-signature": t.String()
34
+ }),
35
+ admin_keys: t.Number(),
36
+ usage: t.Object({
37
+ required: t.String(),
38
+ admin: t.String(),
39
+ optional: t.String(),
40
+ permissions: t.String()
41
+ })
42
+ }, {
43
+ description: 'Crypto Auth plugin information and usage instructions'
44
+ })
45
+
16
46
  // Store config globally for hooks to access
17
47
  let pluginConfig: any = cryptoAuthConfig
18
48
 
@@ -25,38 +55,10 @@ export const cryptoAuthPlugin: Plugin = {
25
55
  category: "auth",
26
56
  tags: ["authentication", "ed25519", "cryptography", "security"],
27
57
  dependencies: [],
28
-
29
- configSchema: {
30
- type: "object",
31
- properties: {
32
- enabled: {
33
- type: "boolean",
34
- description: "Habilitar autenticação criptográfica"
35
- },
36
- maxTimeDrift: {
37
- type: "number",
38
- minimum: 30000,
39
- description: "Máximo drift de tempo permitido em millisegundos (previne replay attacks)"
40
- },
41
- adminKeys: {
42
- type: "array",
43
- items: { type: "string" },
44
- description: "Chaves públicas dos administradores (hex 64 caracteres)"
45
- },
46
- enableMetrics: {
47
- type: "boolean",
48
- description: "Habilitar métricas de autenticação"
49
- }
50
- },
51
- additionalProperties: false
52
- },
53
58
 
54
- defaultConfig: {
55
- enabled: true,
56
- maxTimeDrift: 300000, // 5 minutos
57
- adminKeys: [],
58
- enableMetrics: true
59
- },
59
+ // ✅ Plugin usa sistema declarativo de configuração (plugins/crypto-auth/config/)
60
+ // ❌ Removido: configSchema e defaultConfig (redundante com nova estrutura)
61
+ // 📖 Configuração gerenciada por defineConfig() com type inference automática
60
62
 
61
63
  // CLI Commands
62
64
  commands: [
@@ -86,16 +88,19 @@ export const cryptoAuthPlugin: Plugin = {
86
88
  ;(global as any).cryptoAuthService = authService
87
89
  ;(global as any).cryptoAuthMiddleware = authMiddleware
88
90
 
89
- context.logger.info("✅ Crypto Auth plugin inicializado", {
90
- mode: 'middleware-based',
91
- maxTimeDrift: cryptoAuthConfig.maxTimeDrift,
92
- adminKeys: cryptoAuthConfig.adminKeys.length,
93
- usage: 'Use cryptoAuthRequired(), cryptoAuthAdmin(), cryptoAuthOptional() nas rotas'
91
+ // Store plugin info for table display
92
+ if (!(global as any).__fluxstackPlugins) {
93
+ (global as any).__fluxstackPlugins = []
94
+ }
95
+ (global as any).__fluxstackPlugins.push({
96
+ name: 'Crypto Auth',
97
+ status: 'Active',
98
+ details: `${cryptoAuthConfig.adminKeys.length} admin keys`
94
99
  })
95
100
  },
96
101
 
97
102
  // @ts-ignore - plugin property não está no tipo oficial mas é suportada
98
- plugin: new Elysia({ prefix: "/api/auth" })
103
+ plugin: new Elysia({ prefix: "/api/auth", tags: ['Authentication'] })
99
104
  .get("/info", () => ({
100
105
  name: "FluxStack Crypto Auth",
101
106
  description: "Autenticação baseada em assinatura Ed25519",
@@ -121,7 +126,14 @@ export const cryptoAuthPlugin: Plugin = {
121
126
  optional: "import { cryptoAuthOptional } from '@/plugins/crypto-auth/server'",
122
127
  permissions: "import { cryptoAuthPermissions } from '@/plugins/crypto-auth/server'"
123
128
  }
124
- })),
129
+ }), {
130
+ detail: {
131
+ summary: 'Crypto Auth Plugin Information',
132
+ description: 'Returns information about the Ed25519-based cryptographic authentication system, including how it works, required headers, and usage examples',
133
+ tags: ['Authentication', 'Security', 'Crypto']
134
+ },
135
+ response: AuthInfoResponseSchema
136
+ }),
125
137
 
126
138
  onResponse: async (context: ResponseContext) => {
127
139
  if (!cryptoAuthConfig.enableMetrics) return
@@ -148,14 +160,7 @@ export const cryptoAuthPlugin: Plugin = {
148
160
  },
149
161
 
150
162
  onServerStart: async (context: PluginContext) => {
151
- if (cryptoAuthConfig.enabled) {
152
- context.logger.info("✅ Crypto Auth plugin ativo", {
153
- mode: 'middleware-based',
154
- adminKeys: cryptoAuthConfig.adminKeys.length,
155
- maxTimeDrift: `${cryptoAuthConfig.maxTimeDrift}ms`,
156
- usage: 'Use cryptoAuthRequired(), cryptoAuthAdmin() nas rotas'
157
- })
158
- }
163
+ // Silent - plugin is already initialized
159
164
  }
160
165
  }
161
166
 
@@ -3,7 +3,7 @@
3
3
  * Apenas valida autenticação - routing é feito pelos middlewares Elysia
4
4
  */
5
5
 
6
- import type { RequestContext } from '../../../core/plugins/types'
6
+ import type { RequestContext } from '@/core/plugins/types'
7
7
  import type { CryptoAuthService } from './CryptoAuthService'
8
8
 
9
9
  export interface Logger {
@@ -5,6 +5,21 @@
5
5
 
6
6
  import type { Logger } from '@/core/utils/logger'
7
7
 
8
+ /**
9
+ * Helper to safely parse request.url which might be relative or absolute
10
+ */
11
+ function parseRequestURL(request: Request): URL {
12
+ try {
13
+ // Try parsing as absolute URL first
14
+ return new URL(request.url)
15
+ } catch {
16
+ // If relative, use host from headers or default to localhost
17
+ const host = request.headers.get('host') || 'localhost'
18
+ const protocol = request.headers.get('x-forwarded-proto') || 'http'
19
+ return new URL(request.url, `${protocol}://${host}`)
20
+ }
21
+ }
22
+
8
23
  export interface CryptoAuthUser {
9
24
  publicKey: string
10
25
  isAdmin: boolean
@@ -65,7 +80,7 @@ export function extractAuthHeaders(request: Request): {
65
80
  * Build message for signature verification
66
81
  */
67
82
  export function buildMessage(request: Request): string {
68
- const url = new URL(request.url)
83
+ const url = parseRequestURL(request)
69
84
  return `${request.method}:${url.pathname}`
70
85
  }
71
86