create-fluxstack 1.0.13 → 1.0.15
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/.env.example +29 -29
- package/app/client/README.md +69 -69
- package/app/client/index.html +14 -13
- package/app/client/src/App.tsx +157 -524
- package/app/client/src/components/ErrorBoundary.tsx +107 -0
- package/app/client/src/components/ErrorDisplay.css +365 -0
- package/app/client/src/components/ErrorDisplay.tsx +258 -0
- package/app/client/src/components/FluxStackConfig.tsx +1321 -0
- package/app/client/src/components/HybridLiveCounter.tsx +140 -0
- package/app/client/src/components/LiveClock.tsx +286 -0
- package/app/client/src/components/MainLayout.tsx +390 -0
- package/app/client/src/components/SidebarNavigation.tsx +391 -0
- package/app/client/src/components/StateDemo.tsx +178 -0
- package/app/client/src/components/SystemMonitor.tsx +1038 -0
- package/app/client/src/components/Teste.tsx +104 -0
- package/app/client/src/components/UserProfile.tsx +809 -0
- package/app/client/src/hooks/useAuth.ts +39 -0
- package/app/client/src/hooks/useNotifications.ts +56 -0
- package/app/client/src/lib/eden-api.ts +189 -53
- package/app/client/src/lib/errors.ts +340 -0
- package/app/client/src/lib/hooks/useErrorHandler.ts +258 -0
- package/app/client/src/lib/index.ts +45 -0
- package/app/client/src/main.tsx +3 -2
- package/app/client/src/pages/ApiDocs.tsx +182 -0
- package/app/client/src/pages/Demo.tsx +174 -0
- package/app/client/src/pages/HybridLive.tsx +263 -0
- package/app/client/src/pages/Overview.tsx +155 -0
- package/app/client/src/store/README.md +43 -0
- package/app/client/src/store/index.ts +16 -0
- package/app/client/src/store/slices/uiSlice.ts +151 -0
- package/app/client/src/store/slices/userSlice.ts +161 -0
- package/app/client/src/test/README.md +257 -0
- package/app/client/src/test/setup.ts +70 -0
- package/app/client/src/test/types.ts +12 -0
- package/app/client/src/vite-env.d.ts +1 -1
- package/app/client/tsconfig.app.json +44 -43
- package/app/client/tsconfig.json +7 -7
- package/app/client/tsconfig.node.json +25 -25
- package/app/client/zustand-setup.md +65 -0
- package/app/server/controllers/users.controller.ts +68 -68
- package/app/server/index.ts +9 -1
- package/app/server/live/CounterComponent.ts +191 -0
- package/app/server/live/FluxStackConfig.ts +529 -0
- package/app/server/live/LiveClockComponent.ts +214 -0
- package/app/server/live/SidebarNavigation.ts +156 -0
- package/app/server/live/SystemMonitor.ts +594 -0
- package/app/server/live/SystemMonitorIntegration.ts +151 -0
- package/app/server/live/TesteComponent.ts +87 -0
- package/app/server/live/UserProfileComponent.ts +135 -0
- package/app/server/live/register-components.ts +28 -0
- package/app/server/middleware/auth.ts +136 -0
- package/app/server/middleware/errorHandling.ts +250 -0
- package/app/server/middleware/index.ts +10 -0
- package/app/server/middleware/rateLimit.ts +193 -0
- package/app/server/middleware/requestLogging.ts +215 -0
- package/app/server/middleware/validation.ts +270 -0
- package/app/server/routes/index.ts +14 -2
- package/app/server/routes/upload.ts +92 -0
- package/app/server/routes/users.routes.ts +2 -9
- package/app/server/services/NotificationService.ts +302 -0
- package/app/server/services/UserService.ts +222 -0
- package/app/server/services/index.ts +46 -0
- package/core/cli/commands/plugin-deps.ts +263 -0
- package/core/cli/generators/README.md +339 -0
- package/core/cli/generators/component.ts +770 -0
- package/core/cli/generators/controller.ts +299 -0
- package/core/cli/generators/index.ts +144 -0
- package/core/cli/generators/interactive.ts +228 -0
- package/core/cli/generators/prompts.ts +83 -0
- package/core/cli/generators/route.ts +513 -0
- package/core/cli/generators/service.ts +465 -0
- package/core/cli/generators/template-engine.ts +154 -0
- package/core/cli/generators/types.ts +71 -0
- package/core/cli/generators/utils.ts +192 -0
- package/core/cli/index.ts +69 -0
- package/core/cli/plugin-discovery.ts +16 -85
- package/core/client/fluxstack.ts +17 -0
- package/core/client/hooks/index.ts +7 -0
- package/core/client/hooks/state-validator.ts +130 -0
- package/core/client/hooks/useAuth.ts +49 -0
- package/core/client/hooks/useChunkedUpload.ts +258 -0
- package/core/client/hooks/useHybridLiveComponent.ts +967 -0
- package/core/client/hooks/useWebSocket.ts +373 -0
- package/core/client/index.ts +47 -0
- package/core/client/state/createStore.ts +193 -0
- package/core/client/state/index.ts +15 -0
- package/core/config/env-dynamic.ts +1 -1
- package/core/config/env.ts +2 -1
- package/core/config/runtime-config.ts +3 -3
- package/core/config/schema.ts +84 -49
- package/core/framework/server.ts +30 -0
- package/core/index.ts +25 -0
- package/core/live/ComponentRegistry.ts +399 -0
- package/core/live/types.ts +164 -0
- package/core/plugins/built-in/live-components/commands/create-live-component.ts +1201 -0
- package/core/plugins/built-in/live-components/index.ts +27 -0
- package/core/plugins/built-in/logger/index.ts +1 -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/dependency-manager.ts +384 -0
- package/core/plugins/index.ts +5 -1
- package/core/plugins/manager.ts +7 -3
- package/core/plugins/registry.ts +88 -10
- package/core/plugins/types.ts +11 -11
- package/core/server/framework.ts +43 -0
- package/core/server/index.ts +11 -1
- package/core/server/live/ComponentRegistry.ts +1017 -0
- package/core/server/live/FileUploadManager.ts +272 -0
- package/core/server/live/LiveComponentPerformanceMonitor.ts +930 -0
- package/core/server/live/SingleConnectionManager.ts +0 -0
- package/core/server/live/StateSignature.ts +644 -0
- package/core/server/live/WebSocketConnectionManager.ts +688 -0
- package/core/server/live/websocket-plugin.ts +435 -0
- package/core/server/middleware/errorHandling.ts +141 -0
- package/core/server/middleware/index.ts +16 -0
- package/core/server/plugins/static-files-plugin.ts +232 -0
- package/core/server/services/BaseService.ts +95 -0
- package/core/server/services/ServiceContainer.ts +144 -0
- package/core/server/services/index.ts +9 -0
- package/core/templates/create-project.ts +196 -33
- package/core/testing/index.ts +10 -0
- package/core/testing/setup.ts +74 -0
- package/core/types/build.ts +38 -14
- package/core/types/types.ts +319 -0
- package/core/utils/env-runtime.ts +7 -0
- package/core/utils/errors/handlers.ts +264 -39
- package/core/utils/errors/index.ts +528 -18
- package/core/utils/errors/middleware.ts +114 -0
- package/core/utils/logger/formatters.ts +222 -0
- package/core/utils/logger/index.ts +167 -48
- package/core/utils/logger/middleware.ts +253 -0
- package/core/utils/logger/performance.ts +384 -0
- package/core/utils/logger/transports.ts +365 -0
- package/create-fluxstack.ts +296 -296
- package/fluxstack.config.ts +17 -1
- package/package-template.json +66 -66
- package/package.json +31 -6
- package/public/README.md +16 -0
- package/vite.config.ts +29 -14
- package/.claude/settings.local.json +0 -74
- package/.github/workflows/ci-build-tests.yml +0 -480
- package/.github/workflows/dependency-management.yml +0 -324
- package/.github/workflows/release-validation.yml +0 -355
- package/.kiro/specs/fluxstack-architecture-optimization/design.md +0 -700
- package/.kiro/specs/fluxstack-architecture-optimization/requirements.md +0 -127
- package/.kiro/specs/fluxstack-architecture-optimization/tasks.md +0 -330
- package/CLAUDE.md +0 -200
- package/Dockerfile +0 -58
- package/Dockerfile.backend +0 -52
- package/Dockerfile.frontend +0 -54
- package/README-Docker.md +0 -85
- package/ai-context/00-QUICK-START.md +0 -86
- package/ai-context/README.md +0 -88
- package/ai-context/development/eden-treaty-guide.md +0 -362
- package/ai-context/development/patterns.md +0 -382
- package/ai-context/development/plugins-guide.md +0 -572
- package/ai-context/examples/crud-complete.md +0 -626
- package/ai-context/project/architecture.md +0 -399
- package/ai-context/project/overview.md +0 -213
- package/ai-context/recent-changes/eden-treaty-refactor.md +0 -281
- package/ai-context/recent-changes/type-inference-fix.md +0 -223
- package/ai-context/reference/environment-vars.md +0 -384
- package/ai-context/reference/troubleshooting.md +0 -407
- package/app/client/src/components/TestPage.tsx +0 -453
- package/bun.lock +0 -1063
- package/bunfig.toml +0 -16
- package/core/__tests__/integration.test.ts +0 -227
- package/core/build/index.ts +0 -186
- package/core/config/__tests__/config-loader.test.ts +0 -554
- package/core/config/__tests__/config-merger.test.ts +0 -657
- package/core/config/__tests__/env-converter.test.ts +0 -372
- package/core/config/__tests__/env-processor.test.ts +0 -431
- package/core/config/__tests__/env.test.ts +0 -452
- package/core/config/__tests__/integration.test.ts +0 -418
- package/core/config/__tests__/loader.test.ts +0 -331
- package/core/config/__tests__/schema.test.ts +0 -129
- package/core/config/__tests__/validator.test.ts +0 -318
- package/core/framework/__tests__/server.test.ts +0 -233
- package/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
- package/core/plugins/__tests__/manager.test.ts +0 -398
- package/core/plugins/__tests__/monitoring.test.ts +0 -401
- package/core/plugins/__tests__/registry.test.ts +0 -335
- package/core/utils/__tests__/errors.test.ts +0 -139
- package/core/utils/__tests__/helpers.test.ts +0 -297
- package/core/utils/__tests__/logger.test.ts +0 -141
- package/create-test-app.ts +0 -156
- package/docker-compose.microservices.yml +0 -75
- package/docker-compose.simple.yml +0 -57
- package/docker-compose.yml +0 -71
- package/eslint.config.js +0 -23
- package/flux-cli.ts +0 -214
- package/nginx-lb.conf +0 -37
- package/publish.sh +0 -63
- package/run-clean.ts +0 -26
- package/run-env-tests.ts +0 -313
- package/tailwind.config.js +0 -34
- package/tests/__mocks__/api.ts +0 -56
- package/tests/fixtures/users.ts +0 -69
- package/tests/integration/api/users.routes.test.ts +0 -221
- package/tests/setup.ts +0 -29
- package/tests/unit/app/client/App-simple.test.tsx +0 -56
- package/tests/unit/app/client/App.test.tsx.skip +0 -237
- package/tests/unit/app/client/eden-api.test.ts +0 -186
- package/tests/unit/app/client/simple.test.tsx +0 -23
- package/tests/unit/app/controllers/users.controller.test.ts +0 -150
- package/tests/unit/core/create-project.test.ts.skip +0 -95
- package/tests/unit/core/framework.test.ts +0 -144
- package/tests/unit/core/plugins/logger.test.ts.skip +0 -268
- package/tests/unit/core/plugins/vite.test.ts.disabled +0 -188
- package/tests/utils/test-helpers.ts +0 -61
- package/vitest.config.ts +0 -50
- package/workspace.json +0 -6
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
# 🚨 Troubleshooting - FluxStack
|
|
2
|
-
|
|
3
|
-
> **Guia completo para resolver problemas comuns no FluxStack**
|
|
4
|
-
|
|
5
|
-
## ⚡ **Diagnóstico Rápido**
|
|
6
|
-
|
|
7
|
-
### **🔍 Comandos de Diagnóstico**
|
|
8
|
-
```bash
|
|
9
|
-
# 1. Verificar APIs
|
|
10
|
-
curl http://localhost:3000/api/health
|
|
11
|
-
curl http://localhost:3000/swagger/json
|
|
12
|
-
|
|
13
|
-
# 2. Verificar TypeScript
|
|
14
|
-
bunx tsc --noEmit
|
|
15
|
-
|
|
16
|
-
# 3. Verificar testes
|
|
17
|
-
bun run test
|
|
18
|
-
|
|
19
|
-
# 4. Verificar build
|
|
20
|
-
bun run build
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### **🌐 URLs Importantes**
|
|
24
|
-
- **Backend**: http://localhost:3000
|
|
25
|
-
- **Frontend**: http://localhost:5173
|
|
26
|
-
- **Swagger**: http://localhost:3000/swagger
|
|
27
|
-
- **Health**: http://localhost:3000/api/health
|
|
28
|
-
|
|
29
|
-
## 🔧 **Problemas de Desenvolvimento**
|
|
30
|
-
|
|
31
|
-
### **❌ Erro: "Cannot find module 'vite/module-runner'"**
|
|
32
|
-
```bash
|
|
33
|
-
# Problema: Vite sendo importado em produção
|
|
34
|
-
# Solução: Verificar env vars e plugins
|
|
35
|
-
export NODE_ENV=development
|
|
36
|
-
bun run dev
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### **❌ Types `unknown` no Eden Treaty**
|
|
40
|
-
```typescript
|
|
41
|
-
// ❌ Problema
|
|
42
|
-
const { data, error } = await api.users.get()
|
|
43
|
-
// data é 'unknown' em vez de { users: User[] }
|
|
44
|
-
|
|
45
|
-
// ✅ Solução: Verificar response schemas
|
|
46
|
-
export const usersRoutes = new Elysia()
|
|
47
|
-
.get("/", handler, {
|
|
48
|
-
response: t.Object({
|
|
49
|
-
users: t.Array(t.Object({
|
|
50
|
-
id: t.Number(),
|
|
51
|
-
name: t.String(),
|
|
52
|
-
email: t.String()
|
|
53
|
-
}))
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### **❌ Hot Reload Não Funciona**
|
|
59
|
-
```bash
|
|
60
|
-
# Verificar se Vite já está rodando
|
|
61
|
-
lsof -i :5173 # Mac/Linux
|
|
62
|
-
netstat -ano | findstr :5173 # Windows
|
|
63
|
-
|
|
64
|
-
# Matar processo se necessário
|
|
65
|
-
pkill -f vite # Mac/Linux
|
|
66
|
-
taskkill /F /IM node.exe # Windows
|
|
67
|
-
|
|
68
|
-
# Reiniciar
|
|
69
|
-
bun run dev
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### **❌ Erro de Porta em Uso**
|
|
73
|
-
```bash
|
|
74
|
-
# Verificar processos na porta
|
|
75
|
-
lsof -i :3000 # Backend
|
|
76
|
-
lsof -i :5173 # Frontend
|
|
77
|
-
|
|
78
|
-
# Matar processo
|
|
79
|
-
kill -9 <PID>
|
|
80
|
-
|
|
81
|
-
# Ou usar porta diferente
|
|
82
|
-
PORT=3001 bun run dev
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### **❌ TypeScript Errors Massivos**
|
|
86
|
-
```bash
|
|
87
|
-
# 1. Limpar cache
|
|
88
|
-
rm -rf node_modules/.cache
|
|
89
|
-
rm -rf dist/
|
|
90
|
-
|
|
91
|
-
# 2. Reinstalar
|
|
92
|
-
bun install
|
|
93
|
-
|
|
94
|
-
# 3. Verificar versões
|
|
95
|
-
bunx tsc --version
|
|
96
|
-
bun --version
|
|
97
|
-
|
|
98
|
-
# 4. Restart TypeScript server (VS Code)
|
|
99
|
-
Ctrl+Shift+P → "TypeScript: Restart TS Server"
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## 🌐 **Problemas de API**
|
|
103
|
-
|
|
104
|
-
### **❌ CORS Errors**
|
|
105
|
-
```javascript
|
|
106
|
-
// ❌ Error: CORS policy blocks request
|
|
107
|
-
// ✅ Normal: API (3000) ≠ Frontend (5173)
|
|
108
|
-
|
|
109
|
-
// Verificar se API está respondendo
|
|
110
|
-
fetch('http://localhost:3000/api/health')
|
|
111
|
-
.then(r => r.json())
|
|
112
|
-
.then(console.log)
|
|
113
|
-
|
|
114
|
-
// Eden Treaty deveria lidar automaticamente
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### **❌ 404 Not Found nas Rotas**
|
|
118
|
-
```typescript
|
|
119
|
-
// ❌ Problema: Rota não encontrada
|
|
120
|
-
// ✅ Verificar prefix e estrutura
|
|
121
|
-
|
|
122
|
-
// 1. Verificar export das rotas
|
|
123
|
-
export const apiRoutes = new Elysia({ prefix: "/api" })
|
|
124
|
-
.use(usersRoutes) // ← Rota precisa estar registrada
|
|
125
|
-
|
|
126
|
-
// 2. Verificar URL final
|
|
127
|
-
// users routes com prefix "/users"
|
|
128
|
-
// apiRoutes com prefix "/api"
|
|
129
|
-
// URL final: /api/users
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### **❌ Validation Errors**
|
|
133
|
-
```typescript
|
|
134
|
-
// ❌ Body validation failed
|
|
135
|
-
// ✅ Verificar schema da rota
|
|
136
|
-
|
|
137
|
-
.post("/", handler, {
|
|
138
|
-
body: t.Object({
|
|
139
|
-
name: t.String({ minLength: 2 }), // ← Verificar requisitos
|
|
140
|
-
email: t.String({ format: "email" })
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
// Client request deve corresponder:
|
|
145
|
-
await api.users.post({
|
|
146
|
-
name: "João", // ← String com 2+ chars
|
|
147
|
-
email: "joao@x.com" // ← Email válido
|
|
148
|
-
})
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### **❌ Error Handling Não Funciona**
|
|
152
|
-
```typescript
|
|
153
|
-
// ❌ Problema: Errors não tratados
|
|
154
|
-
const { data, error } = await api.users.get()
|
|
155
|
-
|
|
156
|
-
// ✅ Sempre verificar error primeiro
|
|
157
|
-
if (error) {
|
|
158
|
-
console.log(`API Error: ${error.status} - ${error.message}`)
|
|
159
|
-
return
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Agora data é garantidamente válido
|
|
163
|
-
console.log(data.users)
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
## ⚛️ **Problemas de Frontend**
|
|
167
|
-
|
|
168
|
-
### **❌ React Hook Warnings**
|
|
169
|
-
```typescript
|
|
170
|
-
// ❌ Warning: Can't perform state update on unmounted component
|
|
171
|
-
|
|
172
|
-
// ✅ Solução: Cleanup no useEffect
|
|
173
|
-
useEffect(() => {
|
|
174
|
-
let mounted = true
|
|
175
|
-
|
|
176
|
-
const loadData = async () => {
|
|
177
|
-
const { data, error } = await api.users.get()
|
|
178
|
-
if (mounted && !error) {
|
|
179
|
-
setUsers(data.users)
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
loadData()
|
|
184
|
-
|
|
185
|
-
return () => { mounted = false } // ← Cleanup
|
|
186
|
-
}, [])
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### **❌ State Updates Não Refletem**
|
|
190
|
-
```typescript
|
|
191
|
-
// ❌ Problema: State não atualiza após API call
|
|
192
|
-
|
|
193
|
-
// ✅ Verificar se setState está sendo chamado
|
|
194
|
-
const createUser = async (userData) => {
|
|
195
|
-
const { data, error } = await api.users.post(userData)
|
|
196
|
-
|
|
197
|
-
if (!error && data.success) {
|
|
198
|
-
setUsers(prev => [...prev, data.user]) // ← Crucial!
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### **❌ Infinite Re-renders**
|
|
204
|
-
```typescript
|
|
205
|
-
// ❌ Problema: useEffect sem dependencies
|
|
206
|
-
useEffect(() => {
|
|
207
|
-
loadUsers() // ← Vai chamar infinitamente
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
// ✅ Solução: Dependencies corretas
|
|
211
|
-
useEffect(() => {
|
|
212
|
-
loadUsers()
|
|
213
|
-
}, []) // ← Empty array = run once
|
|
214
|
-
|
|
215
|
-
// ✅ Ou use useCallback
|
|
216
|
-
const loadUsers = useCallback(async () => {
|
|
217
|
-
// ...
|
|
218
|
-
}, [])
|
|
219
|
-
|
|
220
|
-
useEffect(() => {
|
|
221
|
-
loadUsers()
|
|
222
|
-
}, [loadUsers])
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
## 🏗️ **Problemas de Build**
|
|
226
|
-
|
|
227
|
-
### **❌ Build Failures**
|
|
228
|
-
```bash
|
|
229
|
-
# 1. Verificar imports
|
|
230
|
-
# ❌ Problema comum
|
|
231
|
-
import { api } from '../../lib/eden-api' # Path relativo
|
|
232
|
-
import type { User } from '../../../shared/types' # Muitos ../
|
|
233
|
-
|
|
234
|
-
# ✅ Usar path aliases (tsconfig.json)
|
|
235
|
-
import { api } from '@/lib/eden-api'
|
|
236
|
-
import type { User } from '@/shared/types'
|
|
237
|
-
|
|
238
|
-
# 2. Verificar exports
|
|
239
|
-
# Cada arquivo deve ter export padrão ou nomeado correto
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
### **❌ Type Errors na Build**
|
|
243
|
-
```typescript
|
|
244
|
-
// ❌ Problema: Tipos diferentes dev vs build
|
|
245
|
-
// ✅ Verificar tsconfig.json consistency
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
"compilerOptions": {
|
|
249
|
-
"strict": true,
|
|
250
|
-
"skipLibCheck": false, // ← Importante para libs
|
|
251
|
-
"moduleResolution": "bundler"
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
### **❌ Asset Loading Problems**
|
|
257
|
-
```typescript
|
|
258
|
-
// ❌ Problema: Assets não carregam em prod
|
|
259
|
-
// ✅ Usar public/ folder
|
|
260
|
-
|
|
261
|
-
// ❌ Errado
|
|
262
|
-
import logo from '../assets/logo.png'
|
|
263
|
-
|
|
264
|
-
// ✅ Correto
|
|
265
|
-
<img src="/logo.png" /> // File em public/logo.png
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
## 🐳 **Problemas de Docker**
|
|
269
|
-
|
|
270
|
-
### **❌ Docker Build Falha**
|
|
271
|
-
```dockerfile
|
|
272
|
-
# ❌ Problema: Node modules não copiados
|
|
273
|
-
# ✅ Verificar .dockerignore
|
|
274
|
-
|
|
275
|
-
# .dockerignore não deve incluir:
|
|
276
|
-
# node_modules/ ← OK, será reinstalado
|
|
277
|
-
# dist/ ← OK, será gerado
|
|
278
|
-
# .env ← Cuidado: env vars podem ser necessárias
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### **❌ Container Não Inicia**
|
|
282
|
-
```bash
|
|
283
|
-
# Verificar logs
|
|
284
|
-
docker logs <container-id>
|
|
285
|
-
|
|
286
|
-
# Verificar portas
|
|
287
|
-
docker ps
|
|
288
|
-
docker port <container-id>
|
|
289
|
-
|
|
290
|
-
# Verificar conectividade
|
|
291
|
-
curl http://localhost:3000/api/health
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
## 🧪 **Problemas de Testing**
|
|
295
|
-
|
|
296
|
-
### **❌ Tests Falhando**
|
|
297
|
-
```typescript
|
|
298
|
-
// ❌ Problema: API calls em tests
|
|
299
|
-
// ✅ Mock Eden Treaty
|
|
300
|
-
|
|
301
|
-
// tests/setup.ts
|
|
302
|
-
vi.mock('@/lib/eden-api', () => ({
|
|
303
|
-
api: {
|
|
304
|
-
users: {
|
|
305
|
-
get: vi.fn(),
|
|
306
|
-
post: vi.fn()
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}))
|
|
310
|
-
|
|
311
|
-
// test.ts
|
|
312
|
-
import { api } from '@/lib/eden-api'
|
|
313
|
-
|
|
314
|
-
it('should handle users', () => {
|
|
315
|
-
const mockUsers = [{ id: 1, name: 'Test' }]
|
|
316
|
-
vi.mocked(api.users.get).mockResolvedValue({
|
|
317
|
-
data: { users: mockUsers },
|
|
318
|
-
error: undefined
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
// Test component...
|
|
322
|
-
})
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
### **❌ Mock Not Working**
|
|
326
|
-
```typescript
|
|
327
|
-
// ❌ Problema: Mocks não aplicados
|
|
328
|
-
// ✅ Verificar ordem de imports
|
|
329
|
-
|
|
330
|
-
// ❌ Errado
|
|
331
|
-
import { Component } from './Component'
|
|
332
|
-
import { vi } from 'vitest'
|
|
333
|
-
|
|
334
|
-
// ✅ Correto
|
|
335
|
-
import { vi } from 'vitest'
|
|
336
|
-
vi.mock('./api')
|
|
337
|
-
import { Component } from './Component'
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
## 🔧 **Ferramentas de Debug**
|
|
341
|
-
|
|
342
|
-
### **✅ Browser DevTools**
|
|
343
|
-
```javascript
|
|
344
|
-
// Network tab
|
|
345
|
-
// - Verificar requests/responses
|
|
346
|
-
// - Status codes
|
|
347
|
-
// - Headers CORS
|
|
348
|
-
|
|
349
|
-
// Console
|
|
350
|
-
// - Eden Treaty debug
|
|
351
|
-
console.log('API call:', await api.users.get())
|
|
352
|
-
|
|
353
|
-
// React DevTools
|
|
354
|
-
// - Component state
|
|
355
|
-
// - Props debugging
|
|
356
|
-
// - Hook values
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
### **✅ Bun Debugging**
|
|
360
|
-
```bash
|
|
361
|
-
# Debug mode
|
|
362
|
-
DEBUG=* bun run dev
|
|
363
|
-
|
|
364
|
-
# Verbose output
|
|
365
|
-
bun run dev --verbose
|
|
366
|
-
|
|
367
|
-
# Memory usage
|
|
368
|
-
bun run --inspect dev
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### **✅ Elysia Debugging**
|
|
372
|
-
```typescript
|
|
373
|
-
// app/server/index.ts
|
|
374
|
-
app.onError((error) => {
|
|
375
|
-
console.error('Elysia Error:', error)
|
|
376
|
-
return { error: error.message, status: 500 }
|
|
377
|
-
})
|
|
378
|
-
|
|
379
|
-
app.onRequest((request) => {
|
|
380
|
-
console.log(`${request.method} ${request.url}`)
|
|
381
|
-
})
|
|
382
|
-
|
|
383
|
-
app.onResponse((response) => {
|
|
384
|
-
console.log(`Response: ${response.status}`)
|
|
385
|
-
})
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
## 📋 **Checklist de Troubleshooting**
|
|
389
|
-
|
|
390
|
-
### **🔍 Quando algo não funciona:**
|
|
391
|
-
1. **Verificar URLs** - APIs nas portas certas?
|
|
392
|
-
2. **Verificar types** - `bunx tsc --noEmit`
|
|
393
|
-
3. **Verificar console** - Errors no browser/terminal?
|
|
394
|
-
4. **Verificar schemas** - Response schemas definidos?
|
|
395
|
-
5. **Verificar imports** - Paths corretos?
|
|
396
|
-
6. **Reiniciar tudo** - `bun run dev` fresh
|
|
397
|
-
|
|
398
|
-
### **🆘 Quando tudo falha:**
|
|
399
|
-
1. **Clean install**: `rm -rf node_modules && bun install`
|
|
400
|
-
2. **Clear cache**: `rm -rf dist/ .cache/`
|
|
401
|
-
3. **Restart editor**: Recarregar VS Code
|
|
402
|
-
4. **Check docs**: Verificar esta documentação
|
|
403
|
-
5. **Minimal repro**: Isolar o problema
|
|
404
|
-
|
|
405
|
-
---
|
|
406
|
-
|
|
407
|
-
**🎯 90% dos problemas são resolvidos verificando response schemas, imports corretos e reiniciando o dev server!**
|