create-fluxstack 1.5.5 → 1.7.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.
- package/README.md +172 -215
- package/app/client/src/App.tsx +45 -19
- package/app/client/src/components/FluxStackConfig.tsx +1 -1
- package/app/client/src/components/HybridLiveCounter.tsx +1 -1
- package/app/client/src/components/LiveClock.tsx +1 -1
- package/app/client/src/components/MainLayout.tsx +0 -2
- package/app/client/src/components/SidebarNavigation.tsx +1 -1
- package/app/client/src/components/SystemMonitor.tsx +16 -10
- package/app/client/src/components/UserProfile.tsx +1 -1
- package/app/server/live/FluxStackConfig.ts +2 -1
- package/app/server/live/LiveClockComponent.ts +8 -7
- package/app/server/live/SidebarNavigation.ts +2 -1
- package/app/server/live/SystemMonitor.ts +1 -0
- package/app/server/live/UserProfileComponent.ts +36 -30
- package/config/server.config.ts +1 -0
- package/core/build/index.ts +14 -0
- package/core/cli/command-registry.ts +10 -10
- package/core/cli/commands/plugin-deps.ts +13 -5
- package/core/cli/plugin-discovery.ts +1 -1
- package/core/client/LiveComponentsProvider.tsx +414 -0
- package/core/client/hooks/useHybridLiveComponent.ts +194 -530
- package/core/client/index.ts +16 -0
- package/core/framework/server.ts +144 -63
- package/core/index.ts +4 -1
- package/core/plugins/built-in/monitoring/index.ts +1 -1
- package/core/plugins/built-in/static/index.ts +1 -1
- package/core/plugins/built-in/swagger/index.ts +1 -1
- package/core/plugins/built-in/vite/index.ts +1 -1
- package/core/plugins/config.ts +1 -1
- package/core/plugins/discovery.ts +1 -1
- package/core/plugins/executor.ts +1 -1
- package/core/plugins/index.ts +1 -0
- package/core/server/live/ComponentRegistry.ts +3 -1
- package/core/server/live/WebSocketConnectionManager.ts +14 -4
- package/core/server/live/websocket-plugin.ts +453 -434
- package/core/server/middleware/elysia-helpers.ts +3 -5
- package/core/server/plugins/database.ts +1 -1
- package/core/server/plugins/static-files-plugin.ts +1 -1
- package/core/templates/create-project.ts +1 -0
- package/core/types/index.ts +1 -1
- package/core/types/plugin.ts +1 -1
- package/core/types/types.ts +6 -2
- package/core/utils/logger/colors.ts +4 -4
- package/core/utils/logger/index.ts +37 -4
- package/core/utils/logger/winston-logger.ts +1 -1
- package/core/utils/sync-version.ts +67 -0
- package/core/utils/version.ts +6 -5
- package/package.json +3 -2
- package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +1 -1
- package/plugins/crypto-auth/server/middlewares/cryptoAuthOptional.ts +1 -1
- package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +1 -1
- package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +1 -1
- package/vite.config.ts +8 -0
- package/.dockerignore +0 -50
- package/CRYPTO-AUTH-MIDDLEWARE-GUIDE.md +0 -475
- package/CRYPTO-AUTH-MIDDLEWARES.md +0 -473
- package/CRYPTO-AUTH-USAGE.md +0 -491
- package/EXEMPLO-ROTA-PROTEGIDA.md +0 -347
- package/QUICK-START-CRYPTO-AUTH.md +0 -221
- package/app/client/src/components/Teste.tsx +0 -104
- package/app/server/live/TesteComponent.ts +0 -87
- package/test-crypto-auth.ts +0 -101
package/README.md
CHANGED
|
@@ -1,96 +1,126 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-fluxstack
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create modern full-stack TypeScript applications with zero configuration.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/create-fluxstack)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
9
11
|
|
|
10
12
|
```bash
|
|
11
|
-
#
|
|
13
|
+
# scaffold a new FluxStack app
|
|
12
14
|
bunx create-fluxstack my-awesome-app
|
|
13
15
|
|
|
14
|
-
#
|
|
16
|
+
# enter the project and start developing
|
|
15
17
|
cd my-awesome-app
|
|
16
18
|
bun run dev
|
|
17
19
|
```
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
- 🚀 **Backend**: http://localhost:3000
|
|
21
|
-
- ⚛️ **Frontend**: http://localhost:5173
|
|
22
|
-
- 📋 **API Docs**: http://localhost:3000/swagger
|
|
21
|
+
Your development environment will be available at:
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
- **Backend**: http://localhost:3000
|
|
24
|
+
- **Frontend (proxied)**: http://localhost:3000/
|
|
25
|
+
- **API Docs**: http://localhost:3000/swagger
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
- **⚡ Bun Runtime** - 3x faster than Node.js
|
|
28
|
-
- **🚀 Elysia.js** - Ultra-fast backend framework
|
|
29
|
-
- **⚛️ React 19** - Latest React with modern features
|
|
30
|
-
- **🎨 Tailwind CSS v4** - Latest styling framework
|
|
31
|
-
- **📦 Vite 7** - Lightning-fast dev server
|
|
32
|
-
- **🔒 TypeScript 5** - Full type safety end-to-end
|
|
27
|
+
---
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
- **✅ Type Safety** - Eden Treaty for API communication with automatic type inference
|
|
36
|
-
- **✅ Hot Reload** - Backend + Frontend coordinated development
|
|
37
|
-
- **✅ Auto Documentation** - Swagger UI generated from your API
|
|
38
|
-
- **✅ Git Ready** - Repository initialized with proper .gitignore
|
|
39
|
-
- **✅ Production Ready** - Optimized build scripts included
|
|
40
|
-
- **✅ AI Context** - Complete documentation for AI assistants
|
|
29
|
+
## What You Get
|
|
41
30
|
|
|
42
|
-
|
|
31
|
+
### Modern Tech Stack
|
|
32
|
+
- Bun runtime (3x faster than Node.js)
|
|
33
|
+
- Elysia.js backend
|
|
34
|
+
- React 19 + Vite 7 frontend
|
|
35
|
+
- Tailwind CSS v4 styling
|
|
36
|
+
- TypeScript 5 end-to-end typing
|
|
37
|
+
|
|
38
|
+
### Zero-Config Features
|
|
39
|
+
- Automatic Eden Treaty type inference
|
|
40
|
+
- Coordinated hot reload (backend + frontend)
|
|
41
|
+
- Swagger documentation out of the box
|
|
42
|
+
- Production-ready build scripts and Docker templates
|
|
43
|
+
- AI-focused documentation (`ai-context/`)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Architecture Overview
|
|
43
48
|
|
|
44
49
|
```
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
│
|
|
49
|
-
│
|
|
50
|
-
│
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
│
|
|
54
|
-
│
|
|
55
|
-
│
|
|
56
|
-
│
|
|
57
|
-
|
|
58
|
-
│
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
└── README.md # Project documentation
|
|
50
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
51
|
+
│ FluxStack Monorepo │
|
|
52
|
+
├─────────────────────────────────────────────────────────────┤
|
|
53
|
+
│ app/ │
|
|
54
|
+
│ ├─ Frontend (React + Vite) │
|
|
55
|
+
│ ├─ Backend (Elysia + Bun) │
|
|
56
|
+
│ └─ Shared Types / Utils │
|
|
57
|
+
├─────────────────────────────────────────────────────────────┤
|
|
58
|
+
│ core/ │
|
|
59
|
+
│ ├─ Server Framework │
|
|
60
|
+
│ ├─ Plugin System │
|
|
61
|
+
│ └─ Build System │
|
|
62
|
+
├─────────────────────────────────────────────────────────────┤
|
|
63
|
+
│ Communication Layer (Eden Treaty, WebSockets) │
|
|
64
|
+
├─────────────────────────────────────────────────────────────┤
|
|
65
|
+
│ Configuration Management │
|
|
66
|
+
└─────────────────────────────────────────────────────────────┘
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
```
|
|
70
|
+
FluxStack/
|
|
71
|
+
├─ core/ # framework internals (read-only)
|
|
72
|
+
│ ├─ framework/ # FluxStackFramework (Elysia orchestrator)
|
|
73
|
+
│ ├─ plugins/ # built-in plugins (swagger, vite, static, monitoring)
|
|
74
|
+
│ ├─ build/ # bundler, optimizer, Docker scaffolding
|
|
75
|
+
│ ├─ cli/ # flux CLI commands and generators
|
|
76
|
+
│ ├─ config/ # declarative schema helpers
|
|
77
|
+
│ └─ utils/ # logging, environment helpers, etc.
|
|
78
|
+
├─ app/ # your editable application code
|
|
79
|
+
│ ├─ server/ # API routes, controllers, services, live components
|
|
80
|
+
│ │ ├─ controllers/ # business logic
|
|
81
|
+
│ │ ├─ routes/ # endpoints + schemas
|
|
82
|
+
│ │ ├─ types/ # shared types and App export for Eden Treaty
|
|
83
|
+
│ │ └─ live/ # WebSocket live components
|
|
84
|
+
│ ├─ client/ # React SPA (components, pages, hooks, store)
|
|
85
|
+
│ └─ shared/ # cross-layer types/utilities
|
|
86
|
+
├─ config/ # project-specific config built on the schema
|
|
87
|
+
├─ plugins/ # optional external plugins (e.g. crypto-auth)
|
|
88
|
+
├─ ai-context/ # documentation tailored for assistants
|
|
89
|
+
└─ package.json / README.md # project metadata
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Available Scripts
|
|
66
95
|
|
|
67
96
|
```bash
|
|
68
|
-
#
|
|
69
|
-
bun run dev #
|
|
70
|
-
bun run dev
|
|
71
|
-
bun run dev:frontend #
|
|
72
|
-
bun run dev:backend #
|
|
73
|
-
|
|
74
|
-
#
|
|
75
|
-
bun run build #
|
|
76
|
-
bun run start #
|
|
77
|
-
|
|
78
|
-
#
|
|
79
|
-
bun run typecheck #
|
|
80
|
-
bun run test #
|
|
97
|
+
# development
|
|
98
|
+
bun run dev # full stack with proxy + vite
|
|
99
|
+
bun run dev # logs are automatically filtered in development
|
|
100
|
+
bun run dev:frontend # only the frontend (port 5173, no proxy)
|
|
101
|
+
bun run dev:backend # only the backend (port 3001)
|
|
102
|
+
|
|
103
|
+
# production
|
|
104
|
+
bun run build # build backend + frontend + manifest
|
|
105
|
+
bun run start # start production bundle
|
|
106
|
+
|
|
107
|
+
# utilities
|
|
108
|
+
bun run typecheck # run TypeScript type checking
|
|
109
|
+
bun run test # execute Vitest suite
|
|
81
110
|
```
|
|
82
111
|
|
|
83
|
-
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Type-Safe API Development
|
|
84
115
|
|
|
85
|
-
FluxStack
|
|
116
|
+
FluxStack uses Eden Treaty to eliminate manual DTOs.
|
|
86
117
|
|
|
87
|
-
### Backend
|
|
88
|
-
```
|
|
89
|
-
// app/server/routes/users.ts
|
|
118
|
+
### Backend Route (Elysia)
|
|
119
|
+
```ts
|
|
90
120
|
import { Elysia, t } from 'elysia'
|
|
91
121
|
|
|
92
122
|
export const userRoutes = new Elysia({ prefix: '/users' })
|
|
93
|
-
.get('/', () => ({ users:
|
|
123
|
+
.get('/', () => ({ users: listUsers() }))
|
|
94
124
|
.post('/', ({ body }) => createUser(body), {
|
|
95
125
|
body: t.Object({
|
|
96
126
|
name: t.String(),
|
|
@@ -108,105 +138,27 @@ export const userRoutes = new Elysia({ prefix: '/users' })
|
|
|
108
138
|
})
|
|
109
139
|
```
|
|
110
140
|
|
|
111
|
-
### Frontend
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
import { api } from '../lib/eden-api'
|
|
115
|
-
|
|
116
|
-
export function UsersList() {
|
|
117
|
-
const [users, setUsers] = useState<User[]>([])
|
|
118
|
-
|
|
119
|
-
const createUser = async (userData: CreateUserData) => {
|
|
120
|
-
// ✨ Fully typed - no manual type definitions needed!
|
|
121
|
-
const { data, error } = await api.users.post(userData)
|
|
122
|
-
|
|
123
|
-
if (!error) {
|
|
124
|
-
setUsers(prev => [...prev, data.user]) // ✅ TypeScript knows the shape
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<div>
|
|
130
|
-
{users.map(user => (
|
|
131
|
-
<UserCard key={user.id} user={user} />
|
|
132
|
-
))}
|
|
133
|
-
</div>
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
## 🌍 Environment & Configuration
|
|
141
|
+
### Frontend Usage (React)
|
|
142
|
+
```tsx
|
|
143
|
+
import { api } from '@/app/client/src/lib/eden-api'
|
|
139
144
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
PORT=3000
|
|
145
|
-
HOST=localhost
|
|
146
|
-
VITE_PORT=5173
|
|
147
|
-
VITE_API_URL=http://localhost:3000
|
|
148
|
-
|
|
149
|
-
# Add your own variables
|
|
150
|
-
DATABASE_URL=postgresql://localhost:5432/myapp
|
|
151
|
-
JWT_SECRET=your-secret-key
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### Frontend Environment
|
|
155
|
-
```typescript
|
|
156
|
-
// Only VITE_* variables are exposed to frontend
|
|
157
|
-
const apiUrl = import.meta.env.VITE_API_URL
|
|
158
|
-
const appName = import.meta.env.VITE_APP_NAME
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## 🚀 Deployment
|
|
162
|
-
|
|
163
|
-
### Single Server (Recommended)
|
|
164
|
-
```bash
|
|
165
|
-
# Build everything
|
|
166
|
-
bun run build
|
|
167
|
-
|
|
168
|
-
# Start production server
|
|
169
|
-
bun run start
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Separate Deploy
|
|
173
|
-
```bash
|
|
174
|
-
# Backend
|
|
175
|
-
bun run build:backend
|
|
176
|
-
bun dist/index.js
|
|
177
|
-
|
|
178
|
-
# Frontend
|
|
179
|
-
bun run build:frontend
|
|
180
|
-
# Deploy dist/ folder to CDN
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Docker
|
|
184
|
-
```bash
|
|
185
|
-
# Use included Dockerfile
|
|
186
|
-
docker build -t my-app .
|
|
187
|
-
docker run -p 3000:3000 my-app
|
|
188
|
-
```
|
|
145
|
+
const { data: response, error } = await api.users.post({
|
|
146
|
+
name: 'Ada Lovelace',
|
|
147
|
+
email: 'ada@example.com'
|
|
148
|
+
})
|
|
189
149
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
### Install Bun
|
|
195
|
-
```bash
|
|
196
|
-
# macOS/Linux
|
|
197
|
-
curl -fsSL https://bun.sh/install | bash
|
|
198
|
-
|
|
199
|
-
# Windows
|
|
200
|
-
powershell -c "irm bun.sh/install.ps1|iex"
|
|
150
|
+
if (!error && response?.user) {
|
|
151
|
+
console.log(response.user.name)
|
|
152
|
+
}
|
|
201
153
|
```
|
|
202
154
|
|
|
203
|
-
|
|
155
|
+
---
|
|
204
156
|
|
|
205
|
-
##
|
|
157
|
+
## Customisation Highlights
|
|
206
158
|
|
|
207
|
-
###
|
|
208
|
-
```
|
|
209
|
-
// app/server/routes/posts.ts
|
|
159
|
+
### Add a Route
|
|
160
|
+
```ts
|
|
161
|
+
// app/server/routes/posts.ts
|
|
210
162
|
import { Elysia, t } from 'elysia'
|
|
211
163
|
|
|
212
164
|
export const postRoutes = new Elysia({ prefix: '/posts' })
|
|
@@ -220,96 +172,101 @@ export const postRoutes = new Elysia({ prefix: '/posts' })
|
|
|
220
172
|
|
|
221
173
|
// app/server/index.ts
|
|
222
174
|
import { postRoutes } from './routes/posts'
|
|
223
|
-
|
|
224
175
|
app.use(postRoutes)
|
|
225
176
|
```
|
|
226
177
|
|
|
227
|
-
###
|
|
228
|
-
```
|
|
229
|
-
// app/server/plugins/
|
|
178
|
+
### Create a Plugin
|
|
179
|
+
```ts
|
|
180
|
+
// app/server/plugins/audit.ts
|
|
230
181
|
import { Elysia } from 'elysia'
|
|
231
182
|
|
|
232
|
-
export const
|
|
233
|
-
.
|
|
234
|
-
|
|
235
|
-
}))
|
|
236
|
-
.guard({
|
|
237
|
-
beforeHandle({ user, set }) {
|
|
238
|
-
if (!user) {
|
|
239
|
-
set.status = 401
|
|
240
|
-
return { error: 'Unauthorized' }
|
|
241
|
-
}
|
|
242
|
-
}
|
|
183
|
+
export const auditPlugin = new Elysia({ name: 'audit' })
|
|
184
|
+
.onRequest(({ request }) => {
|
|
185
|
+
console.log(`[AUDIT] ${request.method} ${request.url}`)
|
|
243
186
|
})
|
|
244
187
|
```
|
|
245
188
|
|
|
246
|
-
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Documentation & Support
|
|
247
192
|
|
|
248
|
-
|
|
193
|
+
- Full documentation lives in `ai-context/`.
|
|
194
|
+
- Assistant guidelines: `CLAUDE.md`.
|
|
195
|
+
- Quick start for AI agents: `ai-context/00-QUICK-START.md`.
|
|
196
|
+
- Example apps and guides included in `examples/` and `ai-context/`.
|
|
249
197
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
- **🎯 Examples**: Complete CRUD examples included
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Community
|
|
254
201
|
|
|
255
|
-
|
|
202
|
+
- **Issues**: [GitHub Issues](https://github.com/MarcosBrendonDePaula/FluxStack/issues)
|
|
203
|
+
- **Docs**: [Repository Docs](https://github.com/MarcosBrendonDePaula/FluxStack)
|
|
204
|
+
- **Discussions**: [GitHub Discussions](https://github.com/MarcosBrendonDePaula/FluxStack/discussions)
|
|
256
205
|
|
|
257
|
-
|
|
258
|
-
- **📖 Documentation**: [Full docs](https://github.com/MarcosBrendonDePaula/FluxStack)
|
|
259
|
-
- **💬 Discussions**: [GitHub Discussions](https://github.com/MarcosBrendonDePaula/FluxStack/discussions)
|
|
206
|
+
---
|
|
260
207
|
|
|
261
|
-
##
|
|
208
|
+
## Upgrading
|
|
262
209
|
|
|
263
210
|
```bash
|
|
264
|
-
#
|
|
211
|
+
# pull the latest scaffold
|
|
265
212
|
bunx create-fluxstack@latest my-new-app
|
|
266
213
|
|
|
267
|
-
#
|
|
214
|
+
# check current global version
|
|
268
215
|
npm list -g create-fluxstack
|
|
269
216
|
```
|
|
270
217
|
|
|
271
|
-
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Why FluxStack?
|
|
221
|
+
|
|
222
|
+
### Developer Experience
|
|
223
|
+
- Zero configuration – start coding immediately.
|
|
224
|
+
- Type-safe from controllers to components.
|
|
225
|
+
- Hot reload with backend/frontend coordination.
|
|
226
|
+
- Swagger documentation generated automatically.
|
|
272
227
|
|
|
273
|
-
###
|
|
274
|
-
-
|
|
275
|
-
-
|
|
276
|
-
-
|
|
277
|
-
-
|
|
228
|
+
### Performance
|
|
229
|
+
- Bun runtime for fast startup and low memory.
|
|
230
|
+
- Elysia for high-performance API routing.
|
|
231
|
+
- Vite for instant dev server and optimized builds.
|
|
232
|
+
- React 19 for modern UI primitives.
|
|
278
233
|
|
|
279
|
-
###
|
|
280
|
-
-
|
|
281
|
-
-
|
|
282
|
-
-
|
|
283
|
-
-
|
|
234
|
+
### Production Ready
|
|
235
|
+
- Docker multi-stage builds out of the box.
|
|
236
|
+
- Declarative configuration with environment overrides.
|
|
237
|
+
- Unified error handling and logging support.
|
|
238
|
+
- Optional monitoring plugin for metrics/exporters.
|
|
284
239
|
|
|
285
|
-
###
|
|
286
|
-
-
|
|
287
|
-
-
|
|
288
|
-
-
|
|
289
|
-
|
|
240
|
+
### Modern Stack
|
|
241
|
+
- TypeScript 5, React 19, Tailwind v4, Eden Treaty.
|
|
242
|
+
- Shared types everywhere.
|
|
243
|
+
- WebSocket live components built in.
|
|
244
|
+
|
|
245
|
+
---
|
|
290
246
|
|
|
291
|
-
|
|
292
|
-
- **TypeScript 5**: Latest language features
|
|
293
|
-
- **React 19**: Concurrent features, Server Components ready
|
|
294
|
-
- **Tailwind v4**: Latest CSS framework
|
|
295
|
-
- **Eden Treaty**: Revolutionary type-safe API client
|
|
247
|
+
## Requirements
|
|
296
248
|
|
|
297
|
-
|
|
249
|
+
- **Bun** ≥ 1.2.0
|
|
298
250
|
|
|
251
|
+
### Install Bun
|
|
299
252
|
```bash
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
253
|
+
# macOS / Linux
|
|
254
|
+
curl -fsSL https://bun.sh/install | bash
|
|
255
|
+
|
|
256
|
+
# Windows
|
|
257
|
+
powershell -c "irm bun.sh/install.ps1 | iex"
|
|
303
258
|
```
|
|
304
259
|
|
|
305
|
-
|
|
260
|
+
> FluxStack targets the Bun runtime. Node.js is not supported.
|
|
306
261
|
|
|
307
262
|
---
|
|
308
263
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
**Built with ❤️ by the FluxStack Team**
|
|
264
|
+
## Ready to Build?
|
|
312
265
|
|
|
313
|
-
|
|
266
|
+
```bash
|
|
267
|
+
bunx create-fluxstack my-dream-app
|
|
268
|
+
cd my-dream-app
|
|
269
|
+
bun run dev
|
|
270
|
+
```
|
|
314
271
|
|
|
315
|
-
|
|
272
|
+
Welcome to the future of full-stack development.
|
package/app/client/src/App.tsx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react'
|
|
2
2
|
import { api, getErrorMessage } from './lib/eden-api'
|
|
3
|
-
import {
|
|
4
|
-
FaRocket,
|
|
5
|
-
FaCheckCircle, FaTimesCircle,
|
|
6
|
-
|
|
7
|
-
FaServer, FaDatabase, FaShieldAlt, FaBolt, FaLock,
|
|
8
|
-
FaBullseye, FaGlobe, FaFileAlt,
|
|
9
|
-
FaClipboardList, FaFire, FaFlask as FaTest,
|
|
3
|
+
import {
|
|
4
|
+
FaRocket,
|
|
5
|
+
FaCheckCircle, FaTimesCircle, FaBook, FaShieldAlt, FaBolt,
|
|
6
|
+
FaClipboardList, FaFire, FaFlask as FaTest,
|
|
10
7
|
} from 'react-icons/fa'
|
|
11
|
-
import {
|
|
8
|
+
import { Routes, Route, Link } from 'react-router-dom'
|
|
9
|
+
|
|
10
|
+
// Live Components Provider - Singleton WebSocket Connection for All Live Components
|
|
11
|
+
import { LiveComponentsProvider } from '@/core/client'
|
|
12
12
|
|
|
13
13
|
// Import page components
|
|
14
14
|
import { OverviewPage } from './pages/Overview'
|
|
@@ -17,7 +17,6 @@ import { HybridLivePage } from './pages/HybridLive'
|
|
|
17
17
|
import { ApiDocsPage } from './pages/ApiDocs'
|
|
18
18
|
import { CryptoAuthPage } from './pages/CryptoAuthPage'
|
|
19
19
|
import { MainLayout } from './components/MainLayout'
|
|
20
|
-
import { LiveClock } from './components/LiveClock'
|
|
21
20
|
|
|
22
21
|
// State management is now handled by Zustand stores directly
|
|
23
22
|
|
|
@@ -25,7 +24,22 @@ interface User {
|
|
|
25
24
|
id: number
|
|
26
25
|
name: string
|
|
27
26
|
email: string
|
|
28
|
-
createdAt: string
|
|
27
|
+
createdAt: string | Date
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface UsersResponse {
|
|
31
|
+
users: User[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface UserCreateResponse {
|
|
35
|
+
success: boolean
|
|
36
|
+
user?: User
|
|
37
|
+
message?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface UserDeleteResponse {
|
|
41
|
+
success: boolean
|
|
42
|
+
message?: string
|
|
29
43
|
}
|
|
30
44
|
|
|
31
45
|
function AppContent() {
|
|
@@ -44,7 +58,7 @@ function AppContent() {
|
|
|
44
58
|
|
|
45
59
|
const checkApiStatus = async () => {
|
|
46
60
|
try {
|
|
47
|
-
const {
|
|
61
|
+
const { error } = await api.health.get()
|
|
48
62
|
if (error) {
|
|
49
63
|
setApiStatus('offline')
|
|
50
64
|
} else {
|
|
@@ -65,7 +79,7 @@ function AppContent() {
|
|
|
65
79
|
return
|
|
66
80
|
}
|
|
67
81
|
|
|
68
|
-
setUsers(data.users || [])
|
|
82
|
+
setUsers((data as UsersResponse).users || [])
|
|
69
83
|
} catch (error) {
|
|
70
84
|
showMessage('error', getErrorMessage(error))
|
|
71
85
|
} finally {
|
|
@@ -89,13 +103,14 @@ function AppContent() {
|
|
|
89
103
|
return
|
|
90
104
|
}
|
|
91
105
|
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
const createResult = result as UserCreateResponse
|
|
107
|
+
if (createResult.success && createResult.user) {
|
|
108
|
+
setUsers(prev => [...prev, createResult.user!])
|
|
94
109
|
setName('')
|
|
95
110
|
setEmail('')
|
|
96
111
|
showMessage('success', `Usuário ${name} adicionado com sucesso!`)
|
|
97
112
|
} else {
|
|
98
|
-
showMessage('error',
|
|
113
|
+
showMessage('error', createResult.message || 'Erro ao criar usuário')
|
|
99
114
|
}
|
|
100
115
|
} catch (error) {
|
|
101
116
|
showMessage('error', getErrorMessage(error))
|
|
@@ -115,11 +130,12 @@ function AppContent() {
|
|
|
115
130
|
return
|
|
116
131
|
}
|
|
117
132
|
|
|
118
|
-
|
|
133
|
+
const deleteResult = result as UserDeleteResponse
|
|
134
|
+
if (deleteResult.success) {
|
|
119
135
|
setUsers(prev => prev.filter(user => user.id !== userId))
|
|
120
136
|
showMessage('success', `Usuário ${userName} removido com sucesso!`)
|
|
121
137
|
} else {
|
|
122
|
-
showMessage('error',
|
|
138
|
+
showMessage('error', deleteResult.message || 'Erro ao deletar usuário')
|
|
123
139
|
}
|
|
124
140
|
} catch (error) {
|
|
125
141
|
showMessage('error', getErrorMessage(error))
|
|
@@ -297,9 +313,19 @@ function AppContent() {
|
|
|
297
313
|
)
|
|
298
314
|
}
|
|
299
315
|
|
|
300
|
-
// Main App component -
|
|
316
|
+
// Main App component - Wrapped with LiveComponentsProvider for single WebSocket connection
|
|
301
317
|
function App() {
|
|
302
|
-
return
|
|
318
|
+
return (
|
|
319
|
+
<LiveComponentsProvider
|
|
320
|
+
autoConnect={true}
|
|
321
|
+
reconnectInterval={1000}
|
|
322
|
+
maxReconnectAttempts={5}
|
|
323
|
+
heartbeatInterval={30000}
|
|
324
|
+
debug={false}
|
|
325
|
+
>
|
|
326
|
+
<AppContent />
|
|
327
|
+
</LiveComponentsProvider>
|
|
328
|
+
)
|
|
303
329
|
}
|
|
304
330
|
|
|
305
331
|
export default App
|
|
@@ -6,7 +6,6 @@ import { UserProfile } from './UserProfile'
|
|
|
6
6
|
import { SystemMonitor } from './SystemMonitor'
|
|
7
7
|
import { FluxStackConfig } from './FluxStackConfig'
|
|
8
8
|
import { FaHome, FaCog, FaFolder, FaChartBar, FaRocket, FaServer } from 'react-icons/fa'
|
|
9
|
-
import { Teste } from './Teste'
|
|
10
9
|
|
|
11
10
|
// Temporary placeholder components for other pages
|
|
12
11
|
function Dashboard() {
|
|
@@ -128,7 +127,6 @@ function Dashboard() {
|
|
|
128
127
|
</ul>
|
|
129
128
|
</div>
|
|
130
129
|
</div>
|
|
131
|
-
<Teste></Teste>
|
|
132
130
|
</div>
|
|
133
131
|
)
|
|
134
132
|
}
|