create-fluxstack 1.9.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/.dockerignore +1 -2
  2. package/Dockerfile +8 -8
  3. package/LIVE_COMPONENTS_REVIEW.md +781 -0
  4. package/LLMD/INDEX.md +64 -0
  5. package/LLMD/MAINTENANCE.md +197 -0
  6. package/LLMD/MIGRATION.md +156 -0
  7. package/LLMD/config/.gitkeep +1 -0
  8. package/LLMD/config/declarative-system.md +268 -0
  9. package/LLMD/config/environment-vars.md +327 -0
  10. package/LLMD/config/runtime-reload.md +401 -0
  11. package/LLMD/core/.gitkeep +1 -0
  12. package/LLMD/core/build-system.md +599 -0
  13. package/LLMD/core/framework-lifecycle.md +229 -0
  14. package/LLMD/core/plugin-system.md +451 -0
  15. package/LLMD/patterns/.gitkeep +1 -0
  16. package/LLMD/patterns/anti-patterns.md +297 -0
  17. package/LLMD/patterns/project-structure.md +264 -0
  18. package/LLMD/patterns/type-safety.md +440 -0
  19. package/LLMD/reference/.gitkeep +1 -0
  20. package/LLMD/reference/cli-commands.md +250 -0
  21. package/LLMD/reference/plugin-hooks.md +357 -0
  22. package/LLMD/reference/routing.md +39 -0
  23. package/LLMD/reference/troubleshooting.md +364 -0
  24. package/LLMD/resources/.gitkeep +1 -0
  25. package/LLMD/resources/controllers.md +465 -0
  26. package/LLMD/resources/live-components.md +703 -0
  27. package/LLMD/resources/live-rooms.md +482 -0
  28. package/LLMD/resources/live-upload.md +130 -0
  29. package/LLMD/resources/plugins-external.md +617 -0
  30. package/LLMD/resources/routes-eden.md +254 -0
  31. package/README.md +37 -17
  32. package/app/client/index.html +0 -1
  33. package/app/client/src/App.tsx +109 -156
  34. package/app/client/src/components/AppLayout.tsx +68 -0
  35. package/app/client/src/components/BackButton.tsx +13 -0
  36. package/app/client/src/components/DemoPage.tsx +20 -0
  37. package/app/client/src/components/LiveUploadWidget.tsx +204 -0
  38. package/app/client/src/lib/eden-api.ts +85 -65
  39. package/app/client/src/live/ChatDemo.tsx +107 -0
  40. package/app/client/src/live/CounterDemo.tsx +206 -0
  41. package/app/client/src/live/FormDemo.tsx +119 -0
  42. package/app/client/src/live/RoomChatDemo.tsx +242 -0
  43. package/app/client/src/live/UploadDemo.tsx +21 -0
  44. package/app/client/src/main.tsx +13 -10
  45. package/app/client/src/pages/ApiTestPage.tsx +108 -0
  46. package/app/client/src/pages/HomePage.tsx +76 -0
  47. package/app/client/src/vite-env.d.ts +1 -1
  48. package/app/server/app.ts +1 -4
  49. package/app/server/controllers/users.controller.ts +36 -44
  50. package/app/server/index.ts +24 -107
  51. package/app/server/live/LiveChat.ts +77 -0
  52. package/app/server/live/LiveCounter.ts +67 -0
  53. package/app/server/live/LiveForm.ts +63 -0
  54. package/app/server/live/LiveLocalCounter.ts +32 -0
  55. package/app/server/live/LiveRoomChat.ts +285 -0
  56. package/app/server/live/LiveUpload.ts +81 -0
  57. package/app/server/live/register-components.ts +19 -19
  58. package/app/server/routes/index.ts +3 -1
  59. package/app/server/routes/room.routes.ts +117 -0
  60. package/app/server/routes/users.routes.ts +35 -27
  61. package/app/shared/types/index.ts +14 -2
  62. package/config/app.config.ts +2 -62
  63. package/config/client.config.ts +2 -95
  64. package/config/database.config.ts +2 -99
  65. package/config/fluxstack.config.ts +25 -45
  66. package/config/index.ts +57 -38
  67. package/config/monitoring.config.ts +2 -114
  68. package/config/plugins.config.ts +2 -80
  69. package/config/server.config.ts +2 -68
  70. package/config/services.config.ts +2 -130
  71. package/config/system/app.config.ts +29 -0
  72. package/config/system/build.config.ts +49 -0
  73. package/config/system/client.config.ts +68 -0
  74. package/config/system/database.config.ts +17 -0
  75. package/config/system/fluxstack.config.ts +114 -0
  76. package/config/{logger.config.ts → system/logger.config.ts} +3 -1
  77. package/config/system/monitoring.config.ts +114 -0
  78. package/config/system/plugins.config.ts +84 -0
  79. package/config/{runtime.config.ts → system/runtime.config.ts} +1 -1
  80. package/config/system/server.config.ts +68 -0
  81. package/config/system/services.config.ts +46 -0
  82. package/config/{system.config.ts → system/system.config.ts} +1 -1
  83. package/core/build/bundler.ts +4 -1
  84. package/core/build/flux-plugins-generator.ts +325 -325
  85. package/core/build/index.ts +159 -27
  86. package/core/build/live-components-generator.ts +70 -3
  87. package/core/build/optimizer.ts +235 -235
  88. package/core/cli/command-registry.ts +6 -4
  89. package/core/cli/commands/build.ts +79 -0
  90. package/core/cli/commands/create.ts +54 -0
  91. package/core/cli/commands/dev.ts +101 -0
  92. package/core/cli/commands/help.ts +34 -0
  93. package/core/cli/commands/index.ts +34 -0
  94. package/core/cli/commands/make-plugin.ts +90 -0
  95. package/core/cli/commands/plugin-add.ts +197 -0
  96. package/core/cli/commands/plugin-deps.ts +2 -2
  97. package/core/cli/commands/plugin-list.ts +208 -0
  98. package/core/cli/commands/plugin-remove.ts +170 -0
  99. package/core/cli/generators/component.ts +769 -769
  100. package/core/cli/generators/controller.ts +1 -1
  101. package/core/cli/generators/index.ts +146 -146
  102. package/core/cli/generators/interactive.ts +227 -227
  103. package/core/cli/generators/plugin.ts +2 -2
  104. package/core/cli/generators/prompts.ts +82 -82
  105. package/core/cli/generators/route.ts +6 -6
  106. package/core/cli/generators/service.ts +2 -2
  107. package/core/cli/generators/template-engine.ts +4 -3
  108. package/core/cli/generators/types.ts +2 -2
  109. package/core/cli/generators/utils.ts +191 -191
  110. package/core/cli/index.ts +115 -558
  111. package/core/cli/plugin-discovery.ts +2 -2
  112. package/core/client/LiveComponentsProvider.tsx +63 -17
  113. package/core/client/api/eden.ts +183 -0
  114. package/core/client/api/index.ts +11 -0
  115. package/core/client/components/Live.tsx +104 -0
  116. package/core/client/fluxstack.ts +1 -9
  117. package/core/client/hooks/AdaptiveChunkSizer.ts +215 -0
  118. package/core/client/hooks/state-validator.ts +1 -1
  119. package/core/client/hooks/useAuth.ts +48 -48
  120. package/core/client/hooks/useChunkedUpload.ts +170 -69
  121. package/core/client/hooks/useLiveChunkedUpload.ts +87 -0
  122. package/core/client/hooks/useLiveComponent.ts +800 -0
  123. package/core/client/hooks/useLiveUpload.ts +71 -0
  124. package/core/client/hooks/useRoom.ts +409 -0
  125. package/core/client/hooks/useRoomProxy.ts +382 -0
  126. package/core/client/index.ts +18 -51
  127. package/core/client/standalone-entry.ts +8 -0
  128. package/core/client/standalone.ts +74 -53
  129. package/core/client/state/createStore.ts +192 -192
  130. package/core/client/state/index.ts +14 -14
  131. package/core/config/index.ts +70 -291
  132. package/core/config/schema.ts +42 -723
  133. package/core/framework/client.ts +131 -131
  134. package/core/framework/index.ts +7 -7
  135. package/core/framework/server.ts +227 -47
  136. package/core/framework/types.ts +2 -2
  137. package/core/index.ts +23 -4
  138. package/core/live/ComponentRegistry.ts +7 -3
  139. package/core/live/types.ts +77 -0
  140. package/core/plugins/built-in/index.ts +134 -131
  141. package/core/plugins/built-in/live-components/commands/create-live-component.ts +242 -1074
  142. package/core/plugins/built-in/live-components/index.ts +1 -1
  143. package/core/plugins/built-in/monitoring/index.ts +111 -47
  144. package/core/plugins/built-in/static/index.ts +1 -1
  145. package/core/plugins/built-in/swagger/index.ts +68 -265
  146. package/core/plugins/built-in/vite/index.ts +94 -306
  147. package/core/plugins/built-in/vite/vite-dev.ts +82 -0
  148. package/core/plugins/config.ts +9 -7
  149. package/core/plugins/dependency-manager.ts +31 -1
  150. package/core/plugins/discovery.ts +19 -7
  151. package/core/plugins/executor.ts +2 -2
  152. package/core/plugins/index.ts +203 -203
  153. package/core/plugins/manager.ts +27 -39
  154. package/core/plugins/module-resolver.ts +19 -8
  155. package/core/plugins/registry.ts +309 -21
  156. package/core/plugins/types.ts +106 -55
  157. package/core/server/framework.ts +66 -43
  158. package/core/server/index.ts +15 -16
  159. package/core/server/live/ComponentRegistry.ts +91 -75
  160. package/core/server/live/FileUploadManager.ts +41 -31
  161. package/core/server/live/LiveComponentPerformanceMonitor.ts +1 -1
  162. package/core/server/live/LiveRoomManager.ts +261 -0
  163. package/core/server/live/RoomEventBus.ts +234 -0
  164. package/core/server/live/RoomStateManager.ts +172 -0
  165. package/core/server/live/StateSignature.ts +643 -643
  166. package/core/server/live/WebSocketConnectionManager.ts +30 -19
  167. package/core/server/live/auto-generated-components.ts +41 -26
  168. package/core/server/live/index.ts +14 -0
  169. package/core/server/live/websocket-plugin.ts +233 -72
  170. package/core/server/middleware/elysia-helpers.ts +7 -2
  171. package/core/server/middleware/errorHandling.ts +1 -1
  172. package/core/server/middleware/index.ts +31 -31
  173. package/core/server/plugins/database.ts +180 -180
  174. package/core/server/plugins/static-files-plugin.ts +69 -260
  175. package/core/server/plugins/swagger.ts +33 -33
  176. package/core/server/rooms/RoomBroadcaster.ts +357 -0
  177. package/core/server/rooms/RoomSystem.ts +463 -0
  178. package/core/server/rooms/index.ts +13 -0
  179. package/core/server/services/BaseService.ts +1 -1
  180. package/core/server/services/ServiceContainer.ts +1 -1
  181. package/core/server/services/index.ts +8 -8
  182. package/core/templates/create-project.ts +12 -12
  183. package/core/testing/index.ts +9 -9
  184. package/core/testing/setup.ts +73 -73
  185. package/core/types/api.ts +168 -168
  186. package/core/types/build.ts +219 -218
  187. package/core/types/config.ts +56 -26
  188. package/core/types/index.ts +4 -4
  189. package/core/types/plugin.ts +107 -99
  190. package/core/types/types.ts +490 -14
  191. package/core/utils/build-logger.ts +324 -324
  192. package/core/utils/config-schema.ts +480 -480
  193. package/core/utils/env.ts +2 -8
  194. package/core/utils/errors/codes.ts +114 -114
  195. package/core/utils/errors/handlers.ts +36 -1
  196. package/core/utils/errors/index.ts +49 -5
  197. package/core/utils/errors/middleware.ts +113 -113
  198. package/core/utils/helpers.ts +6 -16
  199. package/core/utils/index.ts +17 -17
  200. package/core/utils/logger/colors.ts +114 -114
  201. package/core/utils/logger/config.ts +13 -9
  202. package/core/utils/logger/formatter.ts +82 -82
  203. package/core/utils/logger/group-logger.ts +101 -101
  204. package/core/utils/logger/index.ts +6 -1
  205. package/core/utils/logger/stack-trace.ts +3 -1
  206. package/core/utils/logger/startup-banner.ts +82 -66
  207. package/core/utils/logger/winston-logger.ts +152 -152
  208. package/core/utils/monitoring/index.ts +211 -211
  209. package/core/utils/sync-version.ts +66 -66
  210. package/core/utils/version.ts +1 -1
  211. package/create-fluxstack.ts +8 -7
  212. package/eslint.config.js +23 -23
  213. package/package.json +14 -15
  214. package/plugins/crypto-auth/cli/make-protected-route.command.ts +1 -1
  215. package/plugins/crypto-auth/client/CryptoAuthClient.ts +302 -302
  216. package/plugins/crypto-auth/client/components/index.ts +11 -11
  217. package/plugins/crypto-auth/client/index.ts +11 -11
  218. package/plugins/crypto-auth/config/index.ts +1 -1
  219. package/plugins/crypto-auth/index.ts +4 -4
  220. package/plugins/crypto-auth/package.json +65 -65
  221. package/plugins/crypto-auth/server/AuthMiddleware.ts +1 -1
  222. package/plugins/crypto-auth/server/CryptoAuthService.ts +185 -185
  223. package/plugins/crypto-auth/server/index.ts +21 -21
  224. package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +3 -3
  225. package/plugins/crypto-auth/server/middlewares/cryptoAuthOptional.ts +1 -1
  226. package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +2 -2
  227. package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +2 -2
  228. package/plugins/crypto-auth/server/middlewares/helpers.ts +1 -1
  229. package/plugins/crypto-auth/server/middlewares/index.ts +22 -22
  230. package/plugins/crypto-auth/server/middlewares.ts +19 -19
  231. package/tsconfig.api-strict.json +16 -0
  232. package/tsconfig.json +10 -14
  233. package/{app/client/tsconfig.node.json → tsconfig.node.json} +1 -1
  234. package/types/global.d.ts +29 -29
  235. package/types/vitest.d.ts +8 -8
  236. package/vite.config.ts +38 -62
  237. package/vitest.config.live.ts +10 -9
  238. package/vitest.config.ts +29 -17
  239. package/workspace.json +5 -5
  240. package/app/client/README.md +0 -69
  241. package/app/client/SIMPLIFICATION.md +0 -140
  242. package/app/client/frontend-only.ts +0 -12
  243. package/app/client/tsconfig.app.json +0 -44
  244. package/app/client/tsconfig.json +0 -7
  245. package/app/client/zustand-setup.md +0 -65
  246. package/app/server/backend-only.ts +0 -18
  247. package/app/server/live/LiveClockComponent.ts +0 -215
  248. package/app/server/routes/env-test.ts +0 -110
  249. package/core/client/hooks/index.ts +0 -7
  250. package/core/client/hooks/useHybridLiveComponent.ts +0 -631
  251. package/core/client/hooks/useWebSocket.ts +0 -373
  252. package/core/config/env.ts +0 -546
  253. package/core/config/loader.ts +0 -522
  254. package/core/config/runtime-config.ts +0 -327
  255. package/core/config/validator.ts +0 -540
  256. package/core/server/backend-entry.ts +0 -51
  257. package/core/server/standalone.ts +0 -106
  258. package/core/utils/regenerate-files.ts +0 -69
  259. package/fluxstack.config.ts +0 -354
@@ -1,140 +0,0 @@
1
- # 🎨 FluxStack Client - Simplified Version
2
-
3
- This is a **simplified, single-page version** of the FluxStack client, inspired by the clean and modern design of Vite's landing page.
4
-
5
- ## 🚀 What Changed?
6
-
7
- ### ✅ **Kept (Essential)**
8
- - ✅ **Eden Treaty** - Core type-safe API client
9
- - ✅ **React 19** - Modern React with hooks
10
- - ✅ **Vite 7** - Lightning-fast dev server
11
- - ✅ **TailwindCSS** - Utility-first styling
12
- - ✅ **TypeScript** - Full type safety
13
- - ✅ **react-icons** - Icon library
14
-
15
- ### ❌ **Removed (Complexity)**
16
- - ❌ **React Router** - No more multi-page routing
17
- - ❌ **Zustand** - Removed complex state management (using simple `useState`)
18
- - ❌ **Multiple Pages** - Consolidated into single page (Overview, Demo, HybridLive, ApiDocs, CryptoAuth)
19
- - ❌ **Complex Error System** - Simplified error handling
20
- - ❌ **Navigation System** - No more tabs and complex navigation
21
- - ❌ **Detailed API Status Section** - Replaced with simple badge
22
- - ❌ **Complex Live Component UIs** - Simplified to minimal clock display
23
-
24
- ### ✅ **Kept (Advanced Features)**
25
- - ✅ **LiveComponents** - Live Clock provido via LiveComponent
26
- - ✅ **LiveComponentsProvider** - Full real-time capabilities maintained
27
- - ✅ **Hybrid Live Component** - Clock synced with server in real-time
28
-
29
- ## 📊 Comparison
30
-
31
- | Metric | Before | After | Reduction |
32
- |--------|--------|-------|-----------|
33
- | **Files** | 43 | ~10 | **-76%** |
34
- | **Components** | 11 | 2 | **-82%** |
35
- | **Pages** | 5 | 1 | **-80%** |
36
- | **Dependencies** | 27 | 19 | **-30%** |
37
- | **Lines in App.tsx** | 331 | 213 | **-36%** |
38
- | **Live Components** | 6 complex | 1 minimal | **-83%** |
39
-
40
- ## 🎯 What Does It Show?
41
-
42
- The simplified client demonstrates:
43
-
44
- 1. **🎨 Minimalist Design** - Clean, centered design inspired by Next.js, React, and Vite
45
- 2. **⚡ Simple API Status** - Single badge showing API online/offline
46
- 3. **🚀 Core Features** - 4 feature cards highlighting main capabilities
47
- 4. **🕐 Live Clock** - Real LiveComponent synced with server in real-time
48
- 5. **📖 Quick Actions** - Direct links to API Docs, GitHub, and API Demo
49
- 6. **🔥 Clean but Powerful** - Minimalist UI with full real-time capabilities
50
-
51
- ## 📝 Structure
52
-
53
- ```
54
- app/client/src/
55
- ├── App.tsx # Single-page application (213 lines)
56
- │ # - AppContent component (main UI)
57
- │ # - MinimalLiveClock component (LiveComponent)
58
- │ # - LiveComponentsProvider wrapper
59
- ├── main.tsx # Entry point (simplified)
60
- ├── index.css # Minimal global styles
61
- ├── vite-env.d.ts # Vite type definitions
62
- ├── assets/ # Static assets
63
- │ └── react.svg # React logo
64
- └── lib/ # Core utilities
65
- ├── eden-api.ts # Eden Treaty API client
66
- └── errors.ts # Error handling utilities
67
- ```
68
-
69
- **Total files in src/**: 6 core files (vs 43+ before)
70
-
71
- ## 🎨 Design Philosophy
72
-
73
- Inspired by **Next.js, React, and Vite landing pages**:
74
- - Everything centered vertically and horizontally
75
- - Large animated logo (fire icon with pulse animation)
76
- - Minimal text, maximum impact
77
- - Simple API status badge (online/offline)
78
- - 4 feature cards in responsive grid
79
- - **Live Clock via LiveComponent** - Real-time sync with server
80
- - Clean action buttons at bottom
81
- - No background blob animations (clean and fast)
82
- - Mobile-first responsive design
83
- - **Full Live Components support** - Maintains advanced real-time features
84
-
85
- ## 🔧 How to Use
86
-
87
- ```bash
88
- # Start development server (backend + frontend)
89
- bun run dev
90
-
91
- # Frontend only
92
- bun run dev:frontend
93
-
94
- # Backend only
95
- bun run dev:backend
96
- ```
97
-
98
- The page will automatically show:
99
- - ✅ **Green badge** - Backend is running and healthy
100
- - ⚠️ **Yellow badge** - Checking backend status
101
- - ❌ **Red badge** - Backend is offline
102
-
103
- ## 🎯 When to Use This Version?
104
-
105
- **Use this ultra-simplified version when:**
106
- - You want the cleanest possible presentation
107
- - You're showcasing FluxStack to newcomers or investors
108
- - You need a professional landing page
109
- - You want maximum simplicity (like Next.js/React/Vite)
110
- - You prefer minimalism over features
111
- - You want fast loading and minimal JavaScript
112
-
113
- **Use the full version when:**
114
- - You need multiple pages/routes
115
- - You require complex state management
116
- - You want real-time features (WebSocket)
117
- - You need complete demos (CRUD, Auth, etc.)
118
- - You're building a full application with all features
119
-
120
- ## 💡 Future Enhancements (Optional)
121
-
122
- If you want to extend this simplified version, consider adding:
123
- - [ ] Simple counter demo using Eden Treaty
124
- - [ ] User CRUD with minimal UI
125
- - [ ] Dark/Light theme toggle
126
- - [ ] Smooth scroll to sections
127
- - [ ] More feature cards
128
-
129
- ## 📚 References
130
-
131
- - [FluxStack Documentation](../../ai-context/)
132
- - [Eden Treaty Guide](../../ai-context/development/eden-treaty-guide.md)
133
- - [Vite Documentation](https://vite.dev)
134
- - [React Documentation](https://react.dev)
135
-
136
- ---
137
-
138
- **🎯 Goal**: Provide a clean, simple, and beautiful client that showcases FluxStack's core value proposition without overwhelming complexity.
139
-
140
- **Made with ❤️ by FluxStack Team**
@@ -1,12 +0,0 @@
1
- // Frontend standalone entry point
2
- import { startFrontendOnly } from "@/core/client/standalone"
3
-
4
- // Configuração para frontend standalone
5
- const frontendConfig = {
6
- clientPath: "app/client",
7
- vitePort: (globalThis as any).process?.env?.FRONTEND_PORT || 5173,
8
- apiUrl: (globalThis as any).process?.env?.API_URL || "http://localhost:3001"
9
- }
10
-
11
- // Iniciar apenas o frontend
12
- startFrontendOnly(frontendConfig)
@@ -1,44 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2022",
5
- "useDefineForClassFields": true,
6
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
- "module": "ESNext",
8
- "skipLibCheck": true,
9
-
10
- /* Bundler mode */
11
- "moduleResolution": "bundler",
12
- "allowImportingTsExtensions": true,
13
- "verbatimModuleSyntax": true,
14
- "moduleDetection": "force",
15
- "noEmit": true,
16
- "jsx": "react-jsx",
17
-
18
- /* Path mapping (alias support) */
19
- "baseUrl": ".",
20
- "paths": {
21
- "@/*": ["./src/*"],
22
- "@/components/*": ["./src/components/*"],
23
- "@/utils/*": ["./src/utils/*"],
24
- "@/hooks/*": ["./src/hooks/*"],
25
- "@/assets/*": ["./src/assets/*"],
26
- "@/lib/*": ["./src/lib/*"],
27
- "@/types/*": ["./src/types/*"],
28
- "@/shared/*": ["../shared/*"],
29
- "@/core/*": ["../../core/*"],
30
- "@/config/*": ["../../config/*"],
31
- "fluxstack": ["../../core/client/fluxstack"],
32
- "elysia": ["../../node_modules/elysia"]
33
- },
34
-
35
- /* Linting */
36
- "strict": true,
37
- "noUnusedLocals": true,
38
- "noUnusedParameters": true,
39
- "erasableSyntaxOnly": true,
40
- "noFallthroughCasesInSwitch": true,
41
- "noUncheckedSideEffectImports": true
42
- },
43
- "include": ["src"]
44
- }
@@ -1,7 +0,0 @@
1
- {
2
- "files": [],
3
- "references": [
4
- { "path": "./tsconfig.app.json" },
5
- { "path": "./tsconfig.node.json" }
6
- ]
7
- }
@@ -1,65 +0,0 @@
1
- # Zustand Setup for FluxStack
2
-
3
- ## Installation
4
-
5
- Add Zustand to your project:
6
-
7
- ```bash
8
- # Using npm
9
- npm install zustand
10
-
11
- # Using yarn
12
- yarn add zustand
13
-
14
- # Using pnpm
15
- pnpm add zustand
16
-
17
- # Using bun
18
- bun add zustand
19
- ```
20
-
21
- ## Package.json Dependencies
22
-
23
- Add to your `package.json`:
24
-
25
- ```json
26
- {
27
- "dependencies": {
28
- "zustand": "^4.4.7"
29
- }
30
- }
31
- ```
32
-
33
- ## TypeScript Support
34
-
35
- Zustand has built-in TypeScript support, no additional packages needed.
36
-
37
- ## Optional: DevTools Integration
38
-
39
- For Redux DevTools integration (already included in our stores):
40
-
41
- ```bash
42
- # No additional packages needed - works out of the box
43
- ```
44
-
45
- ## Middleware
46
-
47
- Our stores already use the `persist` middleware. Other useful middleware:
48
-
49
- ```bash
50
- # For more advanced middleware (optional)
51
- npm install immer # For immutable updates
52
- npm install zustand-middleware-yjs # For collaborative editing
53
- ```
54
-
55
- ## Ready to Use
56
-
57
- The FluxStack template already includes:
58
- - ✅ User authentication store
59
- - ✅ UI state store
60
- - ✅ Persistence middleware
61
- - ✅ DevTools integration
62
- - ✅ Utility hooks
63
- - ✅ TypeScript support
64
-
65
- Just start using the stores in your components!
@@ -1,18 +0,0 @@
1
- /**
2
- * Backend Standalone Entry Point
3
- *
4
- * This is a minimal wrapper for starting the backend in standalone mode.
5
- * The core logic is protected in @/core/server/backend-entry.ts
6
- *
7
- * You can customize the configuration here if needed.
8
- */
9
-
10
- import { startBackend, createBackendConfig } from "@/core/server/backend-entry"
11
- import { appInstance } from "./app"
12
- import { serverConfig } from "@/config/server.config"
13
-
14
- // Create backend configuration from declarative config
15
- const backendConfig = createBackendConfig(serverConfig)
16
-
17
- // Start backend in standalone mode
18
- startBackend(appInstance, backendConfig)
@@ -1,215 +0,0 @@
1
- // 🔥 LiveClock - Real-time Clock Live Component
2
- // Automatically updates every second and broadcasts to all connected clients
3
- import { LiveComponent } from "@/core/types/types";
4
-
5
- interface LiveClockState {
6
- currentTime: string; // Formatted time string
7
- timeZone: string; // IANA timezone (e.g., 'America/Sao_Paulo')
8
- format: '12h' | '24h'; // Time format preference
9
- showSeconds: boolean; // Toggle seconds display
10
- showDate: boolean; // Toggle date display
11
- lastSync: Date; // Last sync timestamp
12
- serverUptime: number; // Server uptime in seconds
13
- }
14
-
15
- export class LiveClockComponent extends LiveComponent<LiveClockState> {
16
- private clockInterval: NodeJS.Timeout | null = null;
17
- private startTime: Date;
18
-
19
- constructor(initialState: LiveClockState, ws: any, options?: { room?: string; userId?: string }) {
20
- const now = new Date();
21
- super({
22
- currentTime: now.toLocaleTimeString('pt-BR'),
23
- timeZone: 'America/Sao_Paulo',
24
- format: '24h',
25
- showSeconds: true,
26
- showDate: true,
27
- lastSync: now,
28
- serverUptime: 0,
29
- ...initialState
30
- }, ws, options);
31
-
32
- this.startTime = now;
33
- console.log(`🕐 ${this.constructor.name} created: ${this.id}`);
34
-
35
- // Start the real-time clock immediately
36
- this.startClock();
37
- }
38
-
39
- private startClock() {
40
- // Clear any existing interval
41
- if (this.clockInterval) {
42
- clearInterval(this.clockInterval);
43
- }
44
-
45
- // Update clock every second
46
- this.clockInterval = setInterval(() => {
47
- this.updateClock();
48
- }, 1000);
49
-
50
- // Initial update
51
- this.updateClock();
52
- }
53
-
54
- private updateClock() {
55
- const now = new Date();
56
- const uptimeMs = now.getTime() - this.startTime.getTime();
57
-
58
- let timeString;
59
- if (this.state.format === '12h') {
60
- timeString = now.toLocaleTimeString('en-US', {
61
- hour12: true,
62
- hour: 'numeric',
63
- minute: '2-digit',
64
- second: this.state.showSeconds ? '2-digit' : undefined
65
- });
66
- } else {
67
- timeString = now.toLocaleTimeString('pt-BR', {
68
- hour12: false,
69
- hour: '2-digit',
70
- minute: '2-digit',
71
- second: this.state.showSeconds ? '2-digit' : undefined
72
- });
73
- }
74
-
75
- this.setState({
76
- currentTime: timeString,
77
- lastSync: now,
78
- serverUptime: Math.floor(uptimeMs / 1000)
79
- });
80
-
81
- // Broadcast time update to all connected clients
82
- if (this.room) {
83
- this.broadcast('CLOCK_TICK', {
84
- currentTime: timeString,
85
- timestamp: now.toISOString(),
86
- serverUptime: Math.floor(uptimeMs / 1000)
87
- });
88
- }
89
- }
90
-
91
- async setTimeFormat(payload: { format: '12h' | '24h' }) {
92
- const { format } = payload;
93
-
94
- if (format !== '12h' && format !== '24h') {
95
- throw new Error('Invalid time format. Use "12h" or "24h"');
96
- }
97
-
98
- this.setState({
99
- format,
100
- lastSync: new Date()
101
- });
102
-
103
- // Immediately update the clock display with new format
104
- this.updateClock();
105
-
106
- console.log(`🕐 Time format changed to: ${format}`);
107
- return { success: true, format };
108
- }
109
-
110
- async toggleSeconds(payload?: { showSeconds?: boolean }) {
111
- const showSeconds = payload?.showSeconds ?? !this.state.showSeconds;
112
-
113
- this.setState({
114
- showSeconds,
115
- lastSync: new Date()
116
- });
117
-
118
- // Update clock display immediately
119
- this.updateClock();
120
-
121
- console.log(`🕐 Seconds display: ${showSeconds ? 'ON' : 'OFF'}`);
122
- return { success: true, showSeconds };
123
- }
124
-
125
- async toggleDate(payload?: { showDate?: boolean }) {
126
- const showDate = payload?.showDate ?? !this.state.showDate;
127
-
128
- this.setState({
129
- showDate,
130
- lastSync: new Date()
131
- });
132
-
133
- console.log(`🕐 Date display: ${showDate ? 'ON' : 'OFF'}`);
134
- return { success: true, showDate };
135
- }
136
-
137
- async setTimeZone(payload: { timeZone: string }) {
138
- const { timeZone } = payload;
139
-
140
- // Basic timezone validation
141
- try {
142
- new Date().toLocaleString('en-US', { timeZone });
143
- } catch (error) {
144
- throw new Error(`Invalid timezone: ${timeZone}`);
145
- }
146
-
147
- this.setState({
148
- timeZone,
149
- lastSync: new Date()
150
- });
151
-
152
- console.log(`🕐 Timezone changed to: ${timeZone}`);
153
- return { success: true, timeZone };
154
- }
155
-
156
- async getServerInfo() {
157
- console.log(`🕐 getServerInfo called for component: ${this.id}`);
158
-
159
- const now = new Date();
160
- const uptimeMs = now.getTime() - this.startTime.getTime();
161
-
162
- const result = {
163
- success: true,
164
- info: {
165
- serverTime: now.toISOString(),
166
- localTime: now.toLocaleString('pt-BR'),
167
- uptime: Math.floor(uptimeMs / 1000),
168
- uptimeFormatted: this.formatUptime(Math.floor(uptimeMs / 1000)),
169
- timezone: this.state.timeZone,
170
- componentId: this.id,
171
- startTime: this.startTime.toISOString()
172
- }
173
- };
174
-
175
- console.log(`🕐 getServerInfo result:`, result);
176
- return result;
177
- }
178
-
179
- async syncTime() {
180
- // Force a manual time sync
181
- this.updateClock();
182
-
183
- console.log(`🕐 Manual time sync performed`);
184
- return {
185
- success: true,
186
- syncTime: new Date().toISOString(),
187
- currentTime: this.state.currentTime
188
- };
189
- }
190
-
191
- private formatUptime(seconds: number): string {
192
- const hours = Math.floor(seconds / 3600);
193
- const minutes = Math.floor((seconds % 3600) / 60);
194
- const secs = seconds % 60;
195
-
196
- if (hours > 0) {
197
- return `${hours}h ${minutes}m ${secs}s`;
198
- } else if (minutes > 0) {
199
- return `${minutes}m ${secs}s`;
200
- } else {
201
- return `${secs}s`;
202
- }
203
- }
204
-
205
- public destroy() {
206
- // Clean up the interval when component is destroyed
207
- if (this.clockInterval) {
208
- clearInterval(this.clockInterval);
209
- this.clockInterval = null;
210
- console.log(`🕐 Clock interval cleared for component: ${this.id}`);
211
- }
212
-
213
- super.destroy();
214
- }
215
- }
@@ -1,110 +0,0 @@
1
- /**
2
- * 🔧 Environment Test Route
3
- * Displays current configuration for debugging purposes
4
- */
5
-
6
- import { Elysia, t } from 'elysia'
7
- import { appConfig } from '@/config/app.config'
8
- import { serverConfig } from '@/config/server.config'
9
- import { loggerConfig } from '@/config/logger.config'
10
- import { appRuntimeConfig } from '@/config/runtime.config'
11
- import { helpers } from '@/core/utils/env'
12
-
13
- // Response schema for environment test
14
- const EnvTestResponseSchema = t.Object({
15
- message: t.String(),
16
- timestamp: t.String(),
17
- serverConfig: t.Object({
18
- port: t.Number(),
19
- host: t.String(),
20
- apiPrefix: t.String(),
21
- appName: t.String(),
22
- appVersion: t.String(),
23
- cors: t.Object({
24
- origins: t.Array(t.String()),
25
- methods: t.Array(t.String()),
26
- credentials: t.Boolean()
27
- }),
28
- client: t.Object({
29
- port: t.Number(),
30
- target: t.String(),
31
- sourceMaps: t.Boolean()
32
- }),
33
- features: t.Object({
34
- enableSwagger: t.Boolean(),
35
- enableMetrics: t.Boolean(),
36
- enableMonitoring: t.Boolean()
37
- })
38
- }),
39
- environment: t.Object({
40
- NODE_ENV: t.String(),
41
- DEBUG: t.Boolean(),
42
- LOG_LEVEL: t.String()
43
- }),
44
- urls: t.Object({
45
- server: t.String(),
46
- client: t.String(),
47
- swagger: t.String()
48
- }),
49
- system: t.Object({
50
- version: t.String(),
51
- features: t.Array(t.String())
52
- })
53
- }, {
54
- description: 'Environment and configuration information for debugging'
55
- })
56
-
57
- /**
58
- * Environment test endpoint
59
- * Shows declarative config system information
60
- */
61
- export const envTestRoute = new Elysia({ prefix: '/api', tags: ['Development'] })
62
- .get('/env-test', () => {
63
- return {
64
- message: '⚡ Declarative Config System!',
65
- timestamp: new Date().toISOString(),
66
- serverConfig: {
67
- port: serverConfig.server.port,
68
- host: serverConfig.server.host,
69
- apiPrefix: serverConfig.server.apiPrefix,
70
- appName: appConfig.name,
71
- appVersion: appConfig.version,
72
- cors: {
73
- origins: serverConfig.cors.origins,
74
- methods: serverConfig.cors.methods,
75
- credentials: serverConfig.cors.credentials
76
- },
77
- client: {
78
- port: serverConfig.server.backendPort,
79
- target: 'es2020',
80
- sourceMaps: false
81
- },
82
- features: {
83
- enableSwagger: appRuntimeConfig.values.enableSwagger,
84
- enableMetrics: appRuntimeConfig.values.enableMetrics,
85
- enableMonitoring: appRuntimeConfig.values.enableMonitoring
86
- }
87
- },
88
- environment: {
89
- NODE_ENV: appConfig.env,
90
- DEBUG: appRuntimeConfig.values.enableDebugMode,
91
- LOG_LEVEL: loggerConfig.level
92
- },
93
- urls: {
94
- server: helpers.getServerUrl(),
95
- client: helpers.getClientUrl(),
96
- swagger: `${helpers.getServerUrl()}/swagger`
97
- },
98
- system: {
99
- version: 'declarative-config',
100
- features: ['type-safe', 'validated', 'declarative', 'runtime-reload']
101
- }
102
- }
103
- }, {
104
- detail: {
105
- summary: 'Environment Configuration Test',
106
- description: 'Returns current environment configuration, server settings, and runtime features for debugging and validation',
107
- tags: ['Development', 'Configuration', 'Debug']
108
- },
109
- response: EnvTestResponseSchema
110
- })
@@ -1,7 +0,0 @@
1
- /**
2
- * Core Client Hooks
3
- * FluxStack hook utilities exports
4
- */
5
-
6
- export { createAuthHook } from './useAuth'
7
- export type { AuthHook } from './useAuth'