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
package/core/cli/index.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import { FluxStackBuilder } from "../build"
4
- import { ProjectCreator } from "../templates/create-project"
5
- import { getConfigSync } from "../config"
3
+ import { FluxStackBuilder } from "@/core/build"
4
+ import { ProjectCreator } from "@/core/templates/create-project"
5
+ import { getConfigSync } from "@/core/config"
6
6
  import { cliRegistry } from "./command-registry"
7
7
  import { pluginDiscovery } from "./plugin-discovery"
8
- import { generateCommand, interactiveGenerateCommand } from "./generators/index.js"
9
- import { startGroup, endGroup, logBox, logInGroup } from "../utils/logger/group-logger"
8
+ import { generateCommand, interactiveGenerateCommand } from "./generators/index"
9
+ import { startGroup, endGroup, logBox, logInGroup } from "@/core/utils/logger/group-logger"
10
10
 
11
11
  const command = process.argv[2]
12
12
  const args = process.argv.slice(3)
@@ -138,14 +138,14 @@ Examples:
138
138
  // Grouped startup messages
139
139
  startGroup({
140
140
  title: 'FluxStack Development Server',
141
- icon: '',
141
+ icon: '',
142
142
  color: 'cyan'
143
143
  })
144
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...', '📦')
145
+ logInGroup(`Server: http://localhost:${options.port}`, '')
146
+ logInGroup(`API: http://localhost:${options.port}/api`, '')
147
+ logInGroup(`Swagger: http://localhost:${options.port}/swagger`, '')
148
+ logInGroup('Starting with hot reload...', '')
149
149
 
150
150
  endGroup()
151
151
  console.log('') // Separator line
@@ -325,7 +325,7 @@ Examples:
325
325
  }
326
326
 
327
327
  // Use the plugin generator
328
- const { generatorRegistry } = await import('./generators/index.js')
328
+ const { generatorRegistry } = await import('./generators/index')
329
329
  const pluginGenerator = generatorRegistry.get('plugin')
330
330
 
331
331
  if (!pluginGenerator) {
@@ -356,6 +356,148 @@ Examples:
356
356
  }
357
357
  }
358
358
  })
359
+
360
+ // Frontend command (frontend-only development)
361
+ cliRegistry.register({
362
+ name: 'frontend',
363
+ description: 'Start frontend development server only',
364
+ category: 'Development',
365
+ usage: 'flux frontend [options]',
366
+ examples: [
367
+ 'flux frontend # Start Vite dev server on port 5173',
368
+ 'flux frontend --port 3000 # Start on custom port'
369
+ ],
370
+ options: [
371
+ {
372
+ name: 'port',
373
+ short: 'p',
374
+ description: 'Port for frontend server',
375
+ type: 'number',
376
+ default: 5173
377
+ }
378
+ ],
379
+ handler: async (args, options, context) => {
380
+ console.log("🎨 FluxStack Frontend Development")
381
+ console.log(`🌐 Frontend: http://localhost:${options.port}`)
382
+ console.log("📦 Starting Vite dev server...")
383
+ console.log()
384
+
385
+ const { spawn } = await import("child_process")
386
+ const frontendProcess = spawn("vite", ["--config", "vite.config.ts", "--port", options.port.toString()], {
387
+ stdio: "inherit",
388
+ cwd: process.cwd()
389
+ })
390
+
391
+ process.on('SIGINT', () => {
392
+ frontendProcess.kill('SIGINT')
393
+ process.exit(0)
394
+ })
395
+
396
+ return new Promise((resolve) => {
397
+ frontendProcess.on('exit', resolve)
398
+ })
399
+ }
400
+ })
401
+
402
+ // Backend command (backend-only development)
403
+ cliRegistry.register({
404
+ name: 'backend',
405
+ description: 'Start backend development server only',
406
+ category: 'Development',
407
+ usage: 'flux backend [options]',
408
+ examples: [
409
+ 'flux backend # Start backend on port 3001',
410
+ 'flux backend --port 4000 # Start on custom port'
411
+ ],
412
+ options: [
413
+ {
414
+ name: 'port',
415
+ short: 'p',
416
+ description: 'Port for backend server',
417
+ type: 'number',
418
+ default: 3001
419
+ }
420
+ ],
421
+ handler: async (args, options, context) => {
422
+ console.log("⚡ FluxStack Backend Development")
423
+ console.log(`🚀 API Server: http://localhost:${options.port}`)
424
+ console.log("📦 Starting backend with hot reload...")
425
+ console.log()
426
+
427
+ // Ensure backend-only.ts exists
428
+ const { ensureBackendEntry } = await import("../utils/regenerate-files")
429
+ await ensureBackendEntry()
430
+
431
+ // Start backend with Bun watch for hot reload
432
+ const { spawn } = await import("child_process")
433
+ const backendProcess = spawn("bun", ["--watch", "app/server/backend-only.ts"], {
434
+ stdio: "inherit",
435
+ cwd: process.cwd(),
436
+ env: {
437
+ ...process.env,
438
+ BACKEND_PORT: options.port.toString()
439
+ }
440
+ })
441
+
442
+ // Handle process cleanup
443
+ process.on('SIGINT', () => {
444
+ backendProcess.kill('SIGINT')
445
+ process.exit(0)
446
+ })
447
+
448
+ return new Promise((resolve) => {
449
+ backendProcess.on('exit', resolve)
450
+ })
451
+ }
452
+ })
453
+
454
+ // Start command (production server)
455
+ cliRegistry.register({
456
+ name: 'start',
457
+ description: 'Start production server',
458
+ category: 'Production',
459
+ usage: 'flux start',
460
+ examples: [
461
+ 'flux start # Start production server from dist/'
462
+ ],
463
+ handler: async (args, options, context) => {
464
+ console.log("🚀 Starting FluxStack production server...")
465
+ const { join } = await import("path")
466
+ await import(join(process.cwd(), "dist", "index.js"))
467
+ }
468
+ })
469
+
470
+ // Build:frontend command (shortcut)
471
+ cliRegistry.register({
472
+ name: 'build:frontend',
473
+ description: 'Build frontend only (shortcut for build --frontend-only)',
474
+ category: 'Build',
475
+ usage: 'flux build:frontend',
476
+ examples: [
477
+ 'flux build:frontend # Build only frontend'
478
+ ],
479
+ handler: async (args, options, context) => {
480
+ const config = getConfigSync()
481
+ const builder = new FluxStackBuilder(config)
482
+ await builder.buildClient()
483
+ }
484
+ })
485
+
486
+ // Build:backend command (shortcut)
487
+ cliRegistry.register({
488
+ name: 'build:backend',
489
+ description: 'Build backend only (shortcut for build --backend-only)',
490
+ category: 'Build',
491
+ usage: 'flux build:backend',
492
+ examples: [
493
+ 'flux build:backend # Build only backend'
494
+ ],
495
+ handler: async (args, options, context) => {
496
+ const config = getConfigSync()
497
+ const builder = new FluxStackBuilder(config)
498
+ await builder.buildServer()
499
+ }
500
+ })
359
501
  }
360
502
 
361
503
  // Main CLI logic
@@ -378,185 +520,12 @@ async function main() {
378
520
  process.exit(exitCode)
379
521
  return
380
522
  }
381
-
382
- // Fallback to legacy command handling for backward compatibility
383
- await handleLegacyCommands()
384
- }
385
-
386
- // Legacy command handling for backward compatibility
387
- async function handleLegacyCommands() {
388
- switch (command) {
389
- case "dev":
390
- // Grouped startup messages
391
- startGroup({
392
- title: 'FluxStack Development Server',
393
- icon: '⚡',
394
- color: 'cyan'
395
- })
396
-
397
- logInGroup('Frontend: http://localhost:5173', '🌐')
398
- logInGroup('Backend: http://localhost:3000', '🚀')
399
- logInGroup('Backend inicia Vite programaticamente', '🔄')
400
- logInGroup('Starting backend server...', '📦')
401
-
402
- endGroup()
403
- console.log('') // Separator line
404
-
405
- // Start only backend - it will start Vite programmatically
406
- const { spawn } = await import("child_process")
407
- const devProcess = spawn("bun", ["--watch", "app/server/index.ts"], {
408
- stdio: "inherit",
409
- cwd: process.cwd()
410
- })
411
-
412
- // Handle process cleanup
413
- process.on('SIGINT', () => {
414
- console.log('\n🛑 Shutting down gracefully...')
415
- devProcess.kill('SIGTERM')
416
- setTimeout(() => {
417
- devProcess.kill('SIGKILL')
418
- process.exit(0)
419
- }, 5000)
420
- })
421
-
422
- devProcess.on('close', (code) => {
423
- process.exit(code || 0)
424
- })
425
-
426
- // Keep the CLI running until the child process exits
427
- await new Promise((resolve) => {
428
- devProcess.on('exit', resolve)
429
- })
430
- break
431
-
432
- case "frontend":
433
- console.log("🎨 FluxStack Frontend Development")
434
- console.log("🌐 Frontend: http://localhost:5173")
435
- console.log("📦 Starting Vite dev server...")
436
- console.log()
437
-
438
- const { spawn: spawnFrontend } = await import("child_process")
439
- const frontendProcess = spawnFrontend("vite", ["--config", "vite.config.ts"], {
440
- stdio: "inherit",
441
- cwd: process.cwd()
442
- })
443
-
444
- process.on('SIGINT', () => {
445
- frontendProcess.kill('SIGINT')
446
- process.exit(0)
447
- })
448
- break
449
-
450
- case "backend":
451
- console.log("⚡ FluxStack Backend Development")
452
- console.log("🚀 API Server: http://localhost:3001")
453
- console.log("📦 Starting backend with hot reload...")
454
- console.log()
455
-
456
- // Start backend with Bun watch for hot reload
457
- const { spawn: spawnBackend } = await import("child_process")
458
- const backendProcess = spawnBackend("bun", ["--watch", "app/server/backend-only.ts"], {
459
- stdio: "inherit",
460
- cwd: process.cwd()
461
- })
462
-
463
- // Handle process cleanup
464
- process.on('SIGINT', () => {
465
- backendProcess.kill('SIGINT')
466
- process.exit(0)
467
- })
468
- break
469
-
470
- case "build":
471
- const config = getConfigSync()
472
- const builder = new FluxStackBuilder(config)
473
- await builder.build()
474
- break
475
-
476
- case "build:frontend":
477
- const frontendConfig = getConfigSync()
478
- const frontendBuilder = new FluxStackBuilder(frontendConfig)
479
- await frontendBuilder.buildClient()
480
- break
481
-
482
- case "build:backend":
483
- const backendConfig = getConfigSync()
484
- const backendBuilder = new FluxStackBuilder(backendConfig)
485
- await backendBuilder.buildServer()
486
- break
487
-
488
- case "start":
489
- console.log("🚀 Starting FluxStack production server...")
490
- const { join } = await import("path")
491
- await import(join(process.cwd(), "dist", "index.js"))
492
- break
493
-
494
- case "create":
495
- const projectName = process.argv[3]
496
- const template = process.argv[4]
497
-
498
- if (!projectName) {
499
- console.error("❌ Please provide a project name: flux create my-app")
500
- console.error()
501
- console.error("Usage:")
502
- console.error(" flux create <project-name> [template]")
503
- console.error()
504
- console.error("Templates:")
505
- console.error(" basic Basic FluxStack project (default)")
506
- console.error(" full Full-featured project with examples")
507
- process.exit(1)
508
- }
509
-
510
- // Validate project name
511
- if (!/^[a-zA-Z0-9-_]+$/.test(projectName)) {
512
- console.error("❌ Project name can only contain letters, numbers, hyphens, and underscores")
513
- process.exit(1)
514
- }
515
-
516
- try {
517
- const creator = new ProjectCreator({
518
- name: projectName,
519
- template: template as 'basic' | 'full' || 'basic'
520
- })
521
-
522
- await creator.create()
523
- } catch (error) {
524
- console.error("❌ Failed to create project:", error instanceof Error ? error.message : String(error))
525
- process.exit(1)
526
- }
527
- break
528
523
 
529
- default:
530
- console.log(`
531
- ⚡ FluxStack Framework CLI
532
-
533
- Usage:
534
- flux dev Start full-stack development server
535
- flux frontend Start frontend only (Vite dev server)
536
- flux backend Start backend only (API server)
537
- flux build Build both frontend and backend
538
- flux build:frontend Build frontend only
539
- flux build:backend Build backend only
540
- flux start Start production server
541
- flux create Create new project
542
-
543
- Examples:
544
- flux dev # Full-stack development
545
- flux frontend # Frontend only (port 5173)
546
- flux backend # Backend only (port 3001)
547
- flux create my-app # Create new project
548
-
549
- Alternative commands:
550
- fluxstack dev # Same as flux dev
551
- bun run dev:frontend # Direct frontend start
552
- bun run dev:backend # Direct backend start
553
-
554
- Environment Variables:
555
- FRONTEND_PORT=5173 # Frontend port
556
- BACKEND_PORT=3001 # Backend port
557
- API_URL=http://localhost:3001 # API URL for frontend
558
- `)
559
- }
524
+ // Command not found - show error and help
525
+ console.error(`❌ Unknown command: ${command}`)
526
+ console.error()
527
+ await cliRegistry.execute('help', args)
528
+ process.exit(1)
560
529
  }
561
530
 
562
531
  // Run main CLI
@@ -1,8 +1,8 @@
1
1
  import { existsSync } from 'fs'
2
2
  import { join } from 'path'
3
- import type { FluxStack } from '../plugins/types'
3
+ import type { FluxStack } from '@/core/plugins/types'
4
4
  import { cliRegistry } from './command-registry'
5
- import { logger } from '../utils/logger'
5
+ import { logger } from '@/core/utils/logger'
6
6
 
7
7
  export class CliPluginDiscovery {
8
8
  private loadedPlugins = new Set<string>()
@@ -110,7 +110,7 @@ export class CliPluginDiscovery {
110
110
  }
111
111
  }
112
112
 
113
- private registerPluginCommands(plugin: Plugin): void {
113
+ private registerPluginCommands(plugin: FluxStack.Plugin): void {
114
114
  if (!plugin.commands || this.loadedPlugins.has(plugin.name)) {
115
115
  return
116
116
  }
@@ -3,5 +3,5 @@
3
3
  * FluxStack hook utilities exports
4
4
  */
5
5
 
6
- export { createAuthHook } from './useAuth.js'
7
- export type { AuthHook } from './useAuth.js'
6
+ export { createAuthHook } from './useAuth'
7
+ export type { AuthHook } from './useAuth'
@@ -1,6 +1,6 @@
1
1
  // 🔥 State Validation Utilities
2
2
 
3
- import type { StateValidation, StateConflict, HybridState } from '../../types/types'
3
+ import type { StateValidation, StateConflict, HybridState } from '@/core/types/types'
4
4
 
5
5
  export class StateValidator {
6
6
  /**
@@ -3,7 +3,7 @@
3
3
  * Core FluxStack authentication utilities
4
4
  */
5
5
 
6
- import type { BaseUser, BaseUserStore } from '../state/index.js'
6
+ import type { BaseUser, BaseUserStore } from '../state/index'
7
7
 
8
8
  /**
9
9
  * Create authentication hook for a user store
@@ -5,7 +5,7 @@ import type {
5
5
  FileUploadCompleteMessage,
6
6
  FileUploadProgressResponse,
7
7
  FileUploadCompleteResponse
8
- } from '../../types/types'
8
+ } from '@/core/types/types'
9
9
 
10
10
  export interface ChunkedUploadOptions {
11
11
  chunkSize?: number // Default 64KB
@@ -12,7 +12,7 @@ import type {
12
12
  HybridComponentOptions,
13
13
  WebSocketMessage,
14
14
  WebSocketResponse
15
- } from '../../types/types'
15
+ } from '@/core/types/types'
16
16
 
17
17
  // Client-side state persistence for reconnection
18
18
  interface PersistedComponentState {
@@ -1,7 +1,7 @@
1
1
  // 🔥 WebSocket Hook for Live Components
2
2
 
3
3
  import { useState, useEffect, useCallback, useRef } from 'react'
4
- import type { WebSocketMessage, WebSocketResponse } from '../../types/types'
4
+ import type { WebSocketMessage, WebSocketResponse } from '@/core/types/types'
5
5
 
6
6
  // Re-export types for easier importing
7
7
  export type { WebSocketMessage, WebSocketResponse }
@@ -3,7 +3,7 @@
3
3
  * Handles environment variable processing and precedence
4
4
  */
5
5
 
6
- import { env, helpers } from '../utils/env'
6
+ import { env, helpers } from '@/core/utils/env'
7
7
  import type { FluxStackConfig, LogLevel, BuildTarget, LogFormat } from './schema'
8
8
 
9
9
  export interface EnvironmentInfo {
@@ -417,6 +417,8 @@ export function getEnvironmentRecommendations(environment: string): Partial<Flux
417
417
  target: 'bun' as const,
418
418
  outDir: 'dist',
419
419
  clean: true,
420
+ minify: false,
421
+ treeshake: false,
420
422
  optimization: {
421
423
  minify: false,
422
424
  compress: false,
@@ -459,6 +461,8 @@ export function getEnvironmentRecommendations(environment: string): Partial<Flux
459
461
  target: 'bun' as const,
460
462
  outDir: 'dist',
461
463
  clean: true,
464
+ minify: true,
465
+ treeshake: true,
462
466
  optimization: {
463
467
  minify: true,
464
468
  compress: true,
@@ -6,9 +6,11 @@
6
6
  import { env, createNamespace } from '../utils/env'
7
7
  import type { FluxStackConfig } from './schema'
8
8
  import { defaultFluxStackConfig } from './schema'
9
- import { loggerConfig } from '../../config/logger.config'
10
- import { buildConfig } from '../../config/build.config'
11
- import { appConfig } from '../../config/app.config'
9
+ import { loggerConfig } from '@/config/logger.config'
10
+ import { clientConfig } from '@/config/client.config'
11
+ import { serverConfig } from '@/config/server.config'
12
+ import { monitoringConfig } from '@/config/monitoring.config'
13
+ import { appConfig } from '@/config/app.config'
12
14
 
13
15
  /**
14
16
  * Runtime Configuration Builder
@@ -163,7 +165,7 @@ export const runtimeConfig = {
163
165
  .override('logging.format', 'json')
164
166
  .override('build.optimization.minify', true)
165
167
  .override('build.sourceMaps', false)
166
- .override('monitoring.enabled', buildConfig.monitoringEnabled)
168
+ .override('monitoring.enabled', monitoringConfig.monitoring.enabled)
167
169
  .build()
168
170
  },
169
171
 
@@ -304,14 +306,14 @@ export const configHelpers = {
304
306
  return {
305
307
  port: env.VITE_PORT,
306
308
  proxy: {
307
- target: buildConfig.apiUrl,
308
- changeOrigin: buildConfig.proxyChangeOrigin
309
+ target: clientConfig.proxy.target,
310
+ changeOrigin: clientConfig.proxy.changeOrigin
309
311
  },
310
312
  build: {
311
- outDir: buildConfig.clientBuildDir,
312
- sourceMaps: buildConfig.clientSourceMaps,
313
- minify: buildConfig.clientMinify,
314
- target: buildConfig.clientTarget
313
+ outDir: clientConfig.build.outDir,
314
+ sourceMaps: clientConfig.build.sourceMaps,
315
+ minify: clientConfig.build.minify,
316
+ target: clientConfig.build.target
315
317
  }
316
318
  }
317
319
  }
@@ -1,8 +1,30 @@
1
1
  /**
2
- * Enhanced Configuration Schema for FluxStack
3
- * Provides comprehensive type definitions and JSON schema validation
2
+ * ⚠️ DEPRECATED - Enhanced Configuration Schema for FluxStack
3
+ *
4
+ * This file is DEPRECATED and maintained only for backward compatibility.
5
+ * Please use the new modular config system from /config instead:
6
+ *
7
+ * ✅ NEW WAY:
8
+ * ```ts
9
+ * import { appConfig, serverConfig, clientConfig } from '@/config'
10
+ * ```
11
+ *
12
+ * ❌ OLD WAY (DEPRECATED):
13
+ * ```ts
14
+ * import { FluxStackConfig } from '@/core/config/schema'
15
+ * ```
16
+ *
17
+ * The modular system provides:
18
+ * - Better organization (separated by domain)
19
+ * - Automatic validation
20
+ * - Type inference
21
+ * - Laravel-style declarative schemas
22
+ *
23
+ * This file will be removed in a future version.
24
+ * @deprecated Use /config modular system instead
4
25
  */
5
26
 
27
+
6
28
  export type LogLevel = 'debug' | 'info' | 'warn' | 'error'
7
29
  export type BuildTarget = 'bun' | 'node' | 'docker'
8
30
  export type LogFormat = 'json' | 'pretty'
@@ -187,6 +209,15 @@ export interface FluxStackConfig {
187
209
  auth?: AuthConfig
188
210
  email?: EmailConfig
189
211
  storage?: StorageConfig
212
+ staticFiles?: {
213
+ publicDir?: string
214
+ uploadsDir?: string
215
+ cacheMaxAge?: number
216
+ enableUploads?: boolean
217
+ enablePublic?: boolean
218
+ publicRoute?: string
219
+ uploadsRoute?: string
220
+ }
190
221
 
191
222
  // Environment-specific overrides
192
223
  environments?: {
@@ -1,13 +1,14 @@
1
1
  import { Elysia } from "elysia"
2
- import type { FluxStackConfig, FluxStackContext } from "../types"
3
- import type { FluxStack, PluginContext, PluginUtils } from "../plugins/types"
4
- import { PluginRegistry } from "../plugins/registry"
5
- import { PluginManager } from "../plugins/manager"
6
- import { getConfigSync, getEnvironmentInfo } from "../config"
7
- import { logger } from "../utils/logger"
8
- import { displayStartupBanner, type StartupInfo } from "../utils/logger/startup-banner"
9
- import { createErrorHandler } from "../utils/errors/handlers"
10
- import { createTimer, formatBytes, isProduction, isDevelopment } from "../utils/helpers"
2
+ import type { FluxStackConfig, FluxStackContext } from "@/core/types"
3
+ import type { FluxStack, PluginContext, PluginUtils } from "@/core/plugins/types"
4
+ import { PluginRegistry } from "@/core/plugins/registry"
5
+ import { PluginManager } from "@/core/plugins/manager"
6
+ import { getConfigSync, getEnvironmentInfo } from "@/core/config"
7
+ import { logger } from "@/core/utils/logger"
8
+ import { displayStartupBanner, type StartupInfo } from "@/core/utils/logger/startup-banner"
9
+ import { createErrorHandler } from "@/core/utils/errors/handlers"
10
+ import { createTimer, formatBytes, isProduction, isDevelopment } from "@/core/utils/helpers"
11
+ import type { Plugin } from "@/core/plugins"
11
12
 
12
13
  export class FluxStackFramework {
13
14
  private app: Elysia
@@ -18,6 +19,21 @@ export class FluxStackFramework {
18
19
  private isStarted: boolean = false
19
20
  private requestTimings: Map<string, number> = new Map()
20
21
 
22
+ /**
23
+ * Helper to safely parse request.url which might be relative or absolute
24
+ */
25
+ private parseRequestURL(request: Request): URL {
26
+ try {
27
+ // Try parsing as absolute URL first
28
+ return new URL(request.url)
29
+ } catch {
30
+ // If relative, use host from headers or default to localhost
31
+ const host = request.headers.get('host') || 'localhost'
32
+ const protocol = request.headers.get('x-forwarded-proto') || 'http'
33
+ return new URL(request.url, `${protocol}://${host}`)
34
+ }
35
+ }
36
+
21
37
  constructor(config?: Partial<FluxStackConfig>) {
22
38
  // Load the full configuration
23
39
  const fullConfig = config ? { ...getConfigSync(), ...config } : getConfigSync()
@@ -159,7 +175,7 @@ export class FluxStackFramework {
159
175
  private setupHeadHandler() {
160
176
  // Global HEAD handler to prevent Elysia's automatic HEAD conversion bug
161
177
  this.app.head("*", ({ request, set }) => {
162
- const url = new URL(request.url)
178
+ const url = this.parseRequestURL(request)
163
179
 
164
180
  // Handle API routes
165
181
  if (url.pathname.startsWith(this.context.config.server.apiPrefix)) {
@@ -233,7 +249,7 @@ export class FluxStackFramework {
233
249
  // Setup onRequest hook and onBeforeRoute hook
234
250
  this.app.onRequest(async ({ request, set }) => {
235
251
  const startTime = Date.now()
236
- const url = new URL(request.url)
252
+ const url = this.parseRequestURL(request)
237
253
 
238
254
  // Store start time for duration calculation (using request URL as key)
239
255
  const requestKey = `${request.method}-${url.pathname}-${startTime}`
@@ -274,7 +290,7 @@ export class FluxStackFramework {
274
290
 
275
291
  // Setup onResponse hook
276
292
  this.app.onAfterHandle(async ({ request, response, set }) => {
277
- const url = new URL(request.url)
293
+ const url = this.parseRequestURL(request)
278
294
 
279
295
  // Retrieve start time using the timing key
280
296
  const requestKey = set.headers['x-request-timing-key']
@@ -328,7 +344,7 @@ export class FluxStackFramework {
328
344
 
329
345
  this.app.onError(async ({ error, request, path, set }) => {
330
346
  const startTime = Date.now()
331
- const url = new URL(request.url)
347
+ const url = this.parseRequestURL(request)
332
348
 
333
349
  const errorContext = {
334
350
  request,
@@ -447,7 +463,7 @@ export class FluxStackFramework {
447
463
 
448
464
  private async handleViteProxy(errorContext: any): Promise<Response> {
449
465
  const vitePort = this.context.config.client?.port || 5173
450
- const url = new URL(errorContext.request.url)
466
+ const url = this.parseRequestURL(errorContext.request)
451
467
 
452
468
  try {
453
469
  const viteUrl = `http://localhost:${vitePort}${url.pathname}${url.search}`