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.
- package/.dockerignore +82 -0
- package/.env.example +19 -0
- package/Dockerfile +70 -0
- package/README.md +6 -3
- package/app/client/SIMPLIFICATION.md +140 -0
- package/app/client/frontend-only.ts +1 -1
- package/app/client/src/App.tsx +148 -283
- package/app/client/src/index.css +5 -20
- package/app/client/src/lib/eden-api.ts +53 -220
- package/app/client/src/main.tsx +2 -3
- package/app/server/app.ts +20 -5
- package/app/server/backend-only.ts +15 -12
- package/app/server/controllers/users.controller.ts +57 -31
- package/app/server/index.ts +86 -96
- package/app/server/live/register-components.ts +18 -7
- package/app/server/routes/env-test.ts +110 -0
- package/app/server/routes/index.ts +1 -8
- package/app/server/routes/users.routes.ts +192 -91
- package/config/app.config.ts +2 -54
- package/config/client.config.ts +95 -0
- package/config/fluxstack.config.ts +2 -2
- package/config/index.ts +57 -22
- package/config/monitoring.config.ts +114 -0
- package/config/plugins.config.ts +80 -0
- package/config/runtime.config.ts +0 -17
- package/config/server.config.ts +50 -30
- package/core/build/bundler.ts +17 -16
- package/core/build/flux-plugins-generator.ts +34 -23
- package/core/build/index.ts +32 -31
- package/core/build/live-components-generator.ts +44 -30
- package/core/build/optimizer.ts +37 -17
- package/core/cli/command-registry.ts +4 -14
- package/core/cli/commands/plugin-deps.ts +8 -8
- package/core/cli/generators/component.ts +3 -3
- package/core/cli/generators/controller.ts +4 -4
- package/core/cli/generators/index.ts +8 -8
- package/core/cli/generators/interactive.ts +4 -4
- package/core/cli/generators/plugin.ts +3 -3
- package/core/cli/generators/prompts.ts +1 -1
- package/core/cli/generators/route.ts +27 -11
- package/core/cli/generators/service.ts +5 -5
- package/core/cli/generators/template-engine.ts +1 -1
- package/core/cli/generators/types.ts +1 -1
- package/core/cli/index.ts +158 -189
- package/core/cli/plugin-discovery.ts +3 -3
- package/core/client/hooks/index.ts +2 -2
- package/core/client/hooks/state-validator.ts +1 -1
- package/core/client/hooks/useAuth.ts +1 -1
- package/core/client/hooks/useChunkedUpload.ts +1 -1
- package/core/client/hooks/useHybridLiveComponent.ts +1 -1
- package/core/client/hooks/useWebSocket.ts +1 -1
- package/core/config/env.ts +5 -1
- package/core/config/runtime-config.ts +12 -10
- package/core/config/schema.ts +33 -2
- package/core/framework/server.ts +30 -14
- package/core/framework/types.ts +2 -2
- package/core/index.ts +31 -23
- package/core/live/ComponentRegistry.ts +1 -1
- package/core/plugins/built-in/live-components/commands/create-live-component.ts +1 -1
- package/core/plugins/built-in/live-components/index.ts +1 -1
- package/core/plugins/built-in/monitoring/index.ts +65 -161
- package/core/plugins/built-in/static/index.ts +75 -277
- package/core/plugins/built-in/swagger/index.ts +301 -231
- package/core/plugins/built-in/vite/index.ts +342 -377
- package/core/plugins/config.ts +2 -2
- package/core/plugins/dependency-manager.ts +2 -2
- package/core/plugins/discovery.ts +1 -1
- package/core/plugins/executor.ts +2 -2
- package/core/plugins/manager.ts +19 -4
- package/core/plugins/module-resolver.ts +1 -1
- package/core/plugins/registry.ts +25 -21
- package/core/plugins/types.ts +147 -5
- package/core/server/backend-entry.ts +51 -0
- package/core/server/framework.ts +2 -2
- package/core/server/live/ComponentRegistry.ts +9 -26
- package/core/server/live/FileUploadManager.ts +1 -1
- package/core/server/live/auto-generated-components.ts +26 -0
- package/core/server/live/websocket-plugin.ts +211 -19
- package/core/server/middleware/errorHandling.ts +1 -1
- package/core/server/middleware/index.ts +4 -4
- package/core/server/plugins/database.ts +1 -2
- package/core/server/plugins/static-files-plugin.ts +259 -231
- package/core/server/plugins/swagger.ts +1 -1
- package/core/server/services/BaseService.ts +1 -1
- package/core/server/services/ServiceContainer.ts +1 -1
- package/core/server/services/index.ts +4 -4
- package/core/server/standalone.ts +16 -1
- package/core/testing/index.ts +1 -1
- package/core/testing/setup.ts +1 -1
- package/core/types/plugin.ts +6 -0
- package/core/utils/build-logger.ts +324 -0
- package/core/utils/config-schema.ts +2 -6
- package/core/utils/helpers.ts +14 -9
- package/core/utils/logger/startup-banner.ts +7 -33
- package/core/utils/regenerate-files.ts +69 -0
- package/core/utils/version.ts +6 -6
- package/create-fluxstack.ts +68 -25
- package/fluxstack.config.ts +138 -252
- package/package.json +3 -18
- package/plugins/crypto-auth/index.ts +52 -47
- package/plugins/crypto-auth/server/AuthMiddleware.ts +1 -1
- package/plugins/crypto-auth/server/middlewares/helpers.ts +16 -1
- package/vitest.config.ts +17 -26
- package/app/client/src/App.css +0 -883
- package/app/client/src/components/ErrorBoundary.tsx +0 -107
- package/app/client/src/components/ErrorDisplay.css +0 -365
- package/app/client/src/components/ErrorDisplay.tsx +0 -258
- package/app/client/src/components/FluxStackConfig.tsx +0 -1321
- package/app/client/src/components/HybridLiveCounter.tsx +0 -140
- package/app/client/src/components/LiveClock.tsx +0 -286
- package/app/client/src/components/MainLayout.tsx +0 -388
- package/app/client/src/components/SidebarNavigation.tsx +0 -391
- package/app/client/src/components/StateDemo.tsx +0 -178
- package/app/client/src/components/SystemMonitor.tsx +0 -1044
- package/app/client/src/components/UserProfile.tsx +0 -809
- package/app/client/src/hooks/useAuth.ts +0 -39
- package/app/client/src/hooks/useNotifications.ts +0 -56
- package/app/client/src/lib/errors.ts +0 -340
- package/app/client/src/lib/hooks/useErrorHandler.ts +0 -258
- package/app/client/src/lib/index.ts +0 -45
- package/app/client/src/pages/ApiDocs.tsx +0 -182
- package/app/client/src/pages/CryptoAuthPage.tsx +0 -394
- package/app/client/src/pages/Demo.tsx +0 -174
- package/app/client/src/pages/HybridLive.tsx +0 -263
- package/app/client/src/pages/Overview.tsx +0 -155
- package/app/client/src/store/README.md +0 -43
- package/app/client/src/store/index.ts +0 -16
- package/app/client/src/store/slices/uiSlice.ts +0 -151
- package/app/client/src/store/slices/userSlice.ts +0 -161
- package/app/client/src/test/README.md +0 -257
- package/app/client/src/test/setup.ts +0 -70
- package/app/client/src/test/types.ts +0 -12
- package/app/server/live/CounterComponent.ts +0 -191
- package/app/server/live/FluxStackConfig.ts +0 -534
- package/app/server/live/SidebarNavigation.ts +0 -157
- package/app/server/live/SystemMonitor.ts +0 -595
- package/app/server/live/SystemMonitorIntegration.ts +0 -151
- package/app/server/live/UserProfileComponent.ts +0 -141
- package/app/server/middleware/auth.ts +0 -136
- package/app/server/middleware/errorHandling.ts +0 -252
- package/app/server/middleware/index.ts +0 -10
- package/app/server/middleware/rateLimit.ts +0 -193
- package/app/server/middleware/requestLogging.ts +0 -215
- package/app/server/middleware/validation.ts +0 -270
- package/app/server/routes/config.ts +0 -145
- package/app/server/routes/crypto-auth-demo.routes.ts +0 -167
- package/app/server/routes/example-with-crypto-auth.routes.ts +0 -235
- package/app/server/routes/exemplo-posts.routes.ts +0 -161
- package/app/server/routes/upload.ts +0 -92
- package/app/server/services/NotificationService.ts +0 -302
- package/app/server/services/UserService.ts +0 -222
- package/app/server/services/index.ts +0 -46
- package/app/server/types/index.ts +0 -1
- package/config/build.config.ts +0 -24
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
// 🔥 Example Live Component - Counter
|
|
2
|
-
|
|
3
|
-
import { LiveComponent } from "../../../core/types/types"
|
|
4
|
-
|
|
5
|
-
interface CounterState {
|
|
6
|
-
count: number
|
|
7
|
-
title: string
|
|
8
|
-
step: number
|
|
9
|
-
history: number[]
|
|
10
|
-
lastUpdated: Date
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class CounterComponent extends LiveComponent<CounterState> {
|
|
14
|
-
|
|
15
|
-
constructor(initialState: CounterState, ws: any, options?: { room?: string; userId?: string }) {
|
|
16
|
-
super(initialState, ws, options)
|
|
17
|
-
|
|
18
|
-
// Ensure history is initialized
|
|
19
|
-
if (!this.state.history) {
|
|
20
|
-
this.state.history = []
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Log component creation
|
|
24
|
-
console.log(`🔢 Counter component created: ${this.id}`, {
|
|
25
|
-
initialState,
|
|
26
|
-
room: options?.room,
|
|
27
|
-
userId: options?.userId
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Action: Increment counter
|
|
32
|
-
async increment(amount: number = 1) {
|
|
33
|
-
const newCount = this.state.count + amount
|
|
34
|
-
const newHistory = [...this.state.history, newCount]
|
|
35
|
-
|
|
36
|
-
this.setState({
|
|
37
|
-
count: newCount,
|
|
38
|
-
history: newHistory.slice(-10), // Keep last 10 values
|
|
39
|
-
lastUpdated: new Date()
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
// Broadcast to room if in multi-user mode
|
|
43
|
-
if (this.room) {
|
|
44
|
-
this.broadcast('COUNTER_INCREMENTED', {
|
|
45
|
-
count: newCount,
|
|
46
|
-
amount,
|
|
47
|
-
userId: this.userId
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log(`🔢 Counter incremented to ${newCount} (step: ${amount})`)
|
|
52
|
-
return { success: true, count: newCount }
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Action: Decrement counter
|
|
56
|
-
async decrement(amount: number = 1) {
|
|
57
|
-
const newCount = Math.max(0, this.state.count - amount)
|
|
58
|
-
const newHistory = [...this.state.history, newCount]
|
|
59
|
-
|
|
60
|
-
this.setState({
|
|
61
|
-
count: newCount,
|
|
62
|
-
history: newHistory.slice(-10),
|
|
63
|
-
lastUpdated: new Date()
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
if (this.room) {
|
|
67
|
-
this.broadcast('COUNTER_DECREMENTED', {
|
|
68
|
-
count: newCount,
|
|
69
|
-
amount,
|
|
70
|
-
userId: this.userId
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
console.log(`🔢 Counter decremented to ${newCount} (step: ${amount})`)
|
|
75
|
-
return { success: true, count: newCount }
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Action: Reset counter
|
|
79
|
-
async reset() {
|
|
80
|
-
this.setState({
|
|
81
|
-
count: 0,
|
|
82
|
-
history: [0],
|
|
83
|
-
lastUpdated: new Date()
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
if (this.room) {
|
|
87
|
-
this.broadcast('COUNTER_RESET', {
|
|
88
|
-
userId: this.userId
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
console.log(`🔢 Counter reset`)
|
|
93
|
-
return { success: true, count: 0 }
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Action: Set step size
|
|
97
|
-
async setStep(step: number) {
|
|
98
|
-
this.setState({
|
|
99
|
-
step: Math.max(1, step),
|
|
100
|
-
lastUpdated: new Date()
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
console.log(`🔢 Counter step set to ${step}`)
|
|
104
|
-
return { success: true, step }
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Action: Update title
|
|
108
|
-
async updateTitle(data: { title: string }) {
|
|
109
|
-
const newTitle = data.title.trim()
|
|
110
|
-
|
|
111
|
-
// Validate title
|
|
112
|
-
if (!newTitle || newTitle.length > 50) {
|
|
113
|
-
throw new Error('Title must be 1-50 characters')
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
this.setState({
|
|
117
|
-
title: newTitle,
|
|
118
|
-
lastUpdated: new Date()
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
console.log(`📝 Title updated to: "${newTitle}"`)
|
|
122
|
-
return { success: true, title: newTitle }
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Action: Set title
|
|
126
|
-
async setTitle(title: string) {
|
|
127
|
-
this.setState({
|
|
128
|
-
title: title.substring(0, 50), // Max 50 chars
|
|
129
|
-
lastUpdated: new Date()
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
console.log(`🔢 Counter title set to "${title}"`)
|
|
133
|
-
return { success: true, title }
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Action: Bulk update
|
|
137
|
-
async bulkUpdate(updates: { count?: number; title?: string; step?: number }) {
|
|
138
|
-
const newState: Partial<CounterState> = {
|
|
139
|
-
lastUpdated: new Date()
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (updates.count !== undefined) {
|
|
143
|
-
newState.count = Math.max(0, updates.count)
|
|
144
|
-
newState.history = [...this.state.history, updates.count].slice(-10)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (updates.title !== undefined) {
|
|
148
|
-
newState.title = updates.title.substring(0, 50)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (updates.step !== undefined) {
|
|
152
|
-
newState.step = Math.max(1, updates.step)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
this.setState(newState)
|
|
156
|
-
|
|
157
|
-
if (this.room) {
|
|
158
|
-
this.broadcast('COUNTER_BULK_UPDATE', {
|
|
159
|
-
updates: newState,
|
|
160
|
-
userId: this.userId
|
|
161
|
-
})
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
console.log(`🔢 Counter bulk updated`, updates)
|
|
165
|
-
return { success: true, updates: newState }
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Get computed properties
|
|
169
|
-
async getStats() {
|
|
170
|
-
const { count, history, step } = this.state
|
|
171
|
-
|
|
172
|
-
const stats = {
|
|
173
|
-
current: count,
|
|
174
|
-
min: Math.min(...history),
|
|
175
|
-
max: Math.max(...history),
|
|
176
|
-
average: history.reduce((a, b) => a + b, 0) / history.length,
|
|
177
|
-
step,
|
|
178
|
-
historyLength: history.length,
|
|
179
|
-
canIncrement: true,
|
|
180
|
-
canDecrement: count > 0
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return { success: true, stats }
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Override destroy for cleanup
|
|
187
|
-
public destroy() {
|
|
188
|
-
console.log(`🗑️ Counter component ${this.id} destroyed`)
|
|
189
|
-
super.destroy()
|
|
190
|
-
}
|
|
191
|
-
}
|
|
@@ -1,534 +0,0 @@
|
|
|
1
|
-
// 🔥 FluxStack Configuration Live Component
|
|
2
|
-
|
|
3
|
-
import { LiveComponent } from '@/core/types/types'
|
|
4
|
-
import { appConfig } from '@/config/app.config'
|
|
5
|
-
import { serverConfig } from '@/config/server.config'
|
|
6
|
-
import { loggerConfig } from '@/config/logger.config'
|
|
7
|
-
import { systemConfig, systemRuntimeInfo } from '@/config/system.config'
|
|
8
|
-
import { FLUXSTACK_VERSION } from '@/core/utils/version'
|
|
9
|
-
|
|
10
|
-
export interface FluxStackConfigState {
|
|
11
|
-
// Environment Configuration
|
|
12
|
-
environment: 'development' | 'production' | 'test'
|
|
13
|
-
port: number
|
|
14
|
-
host: string
|
|
15
|
-
apiPrefix: string
|
|
16
|
-
|
|
17
|
-
// Framework Information
|
|
18
|
-
framework: {
|
|
19
|
-
name: string
|
|
20
|
-
version: string
|
|
21
|
-
description: string
|
|
22
|
-
author: string
|
|
23
|
-
license: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Plugin Configuration
|
|
27
|
-
plugins: Array<{
|
|
28
|
-
name: string
|
|
29
|
-
version: string
|
|
30
|
-
enabled: boolean
|
|
31
|
-
dependencies: string[]
|
|
32
|
-
config?: Record<string, any>
|
|
33
|
-
}>
|
|
34
|
-
|
|
35
|
-
// Runtime Configuration
|
|
36
|
-
runtime: {
|
|
37
|
-
nodeVersion: string
|
|
38
|
-
bunVersion: string
|
|
39
|
-
platform: string
|
|
40
|
-
architecture: string
|
|
41
|
-
cpuCount: number
|
|
42
|
-
totalMemory: number
|
|
43
|
-
workingDirectory: string
|
|
44
|
-
executablePath: string
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Live Components Configuration
|
|
48
|
-
liveComponents: {
|
|
49
|
-
enabled: boolean
|
|
50
|
-
autoDiscovery: boolean
|
|
51
|
-
websocketPath: string
|
|
52
|
-
signatureSecret: string
|
|
53
|
-
maxConnections: number
|
|
54
|
-
timeout: number
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Vite Configuration
|
|
58
|
-
vite: {
|
|
59
|
-
enabled: boolean
|
|
60
|
-
port: number
|
|
61
|
-
host: string
|
|
62
|
-
hmr: boolean
|
|
63
|
-
publicDir: string
|
|
64
|
-
buildDir: string
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Static Files Configuration
|
|
68
|
-
staticFiles: {
|
|
69
|
-
enabled: boolean
|
|
70
|
-
publicPath: string
|
|
71
|
-
uploadsPath: string
|
|
72
|
-
maxFileSize: number
|
|
73
|
-
allowedExtensions: string[]
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Swagger Configuration
|
|
77
|
-
swagger: {
|
|
78
|
-
enabled: boolean
|
|
79
|
-
title: string
|
|
80
|
-
version: string
|
|
81
|
-
description: string
|
|
82
|
-
path: string
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Security Configuration
|
|
86
|
-
security: {
|
|
87
|
-
cors: {
|
|
88
|
-
enabled: boolean
|
|
89
|
-
origins: string[]
|
|
90
|
-
credentials: boolean
|
|
91
|
-
}
|
|
92
|
-
rateLimit: {
|
|
93
|
-
enabled: boolean
|
|
94
|
-
windowMs: number
|
|
95
|
-
maxRequests: number
|
|
96
|
-
}
|
|
97
|
-
helmet: {
|
|
98
|
-
enabled: boolean
|
|
99
|
-
options: Record<string, any>
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Performance Configuration
|
|
104
|
-
performance: {
|
|
105
|
-
compression: boolean
|
|
106
|
-
cache: {
|
|
107
|
-
enabled: boolean
|
|
108
|
-
maxAge: number
|
|
109
|
-
strategy: string
|
|
110
|
-
}
|
|
111
|
-
clustering: {
|
|
112
|
-
enabled: boolean
|
|
113
|
-
workers: number
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Database Configuration (if applicable)
|
|
118
|
-
database: {
|
|
119
|
-
enabled: boolean
|
|
120
|
-
type?: string
|
|
121
|
-
host?: string
|
|
122
|
-
port?: number
|
|
123
|
-
name?: string
|
|
124
|
-
ssl?: boolean
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Logging Configuration
|
|
128
|
-
logging: {
|
|
129
|
-
level: 'debug' | 'info' | 'warn' | 'error'
|
|
130
|
-
format: 'json' | 'pretty' | 'compact'
|
|
131
|
-
file: {
|
|
132
|
-
enabled: boolean
|
|
133
|
-
path?: string
|
|
134
|
-
maxSize?: string
|
|
135
|
-
maxFiles?: number
|
|
136
|
-
}
|
|
137
|
-
console: {
|
|
138
|
-
enabled: boolean
|
|
139
|
-
colors: boolean
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Advanced Configuration
|
|
144
|
-
advanced: {
|
|
145
|
-
hotReload: boolean
|
|
146
|
-
typeChecking: boolean
|
|
147
|
-
sourceMap: boolean
|
|
148
|
-
minification: boolean
|
|
149
|
-
bundleAnalyzer: boolean
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
lastUpdated: number
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export class FluxStackConfig extends LiveComponent<FluxStackConfigState> {
|
|
156
|
-
|
|
157
|
-
constructor(initialState: FluxStackConfigState, ws: any, options?: any) {
|
|
158
|
-
super(initialState, ws, options)
|
|
159
|
-
|
|
160
|
-
// Set default state with real configuration
|
|
161
|
-
this.state = {
|
|
162
|
-
environment: appConfig.env,
|
|
163
|
-
port: serverConfig.port,
|
|
164
|
-
host: serverConfig.host,
|
|
165
|
-
apiPrefix: serverConfig.apiPrefix,
|
|
166
|
-
|
|
167
|
-
framework: {
|
|
168
|
-
name: 'FluxStack',
|
|
169
|
-
version: FLUXSTACK_VERSION,
|
|
170
|
-
description: 'Modern Full-Stack TypeScript Framework with Live Components',
|
|
171
|
-
author: 'FluxStack Team',
|
|
172
|
-
license: 'MIT'
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
plugins: this.getPluginConfiguration(),
|
|
176
|
-
runtime: this.getRuntimeConfiguration(),
|
|
177
|
-
liveComponents: this.getLiveComponentsConfiguration(),
|
|
178
|
-
vite: this.getViteConfiguration(),
|
|
179
|
-
staticFiles: this.getStaticFilesConfiguration(),
|
|
180
|
-
swagger: this.getSwaggerConfiguration(),
|
|
181
|
-
security: this.getSecurityConfiguration(),
|
|
182
|
-
performance: this.getPerformanceConfiguration(),
|
|
183
|
-
database: this.getDatabaseConfiguration(),
|
|
184
|
-
logging: this.getLoggingConfiguration(),
|
|
185
|
-
advanced: this.getAdvancedConfiguration(),
|
|
186
|
-
|
|
187
|
-
lastUpdated: Date.now(),
|
|
188
|
-
...initialState
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
console.log('⚙️ FluxStackConfig component created:', this.id)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Get plugin configuration
|
|
195
|
-
private getPluginConfiguration() {
|
|
196
|
-
return [
|
|
197
|
-
{
|
|
198
|
-
name: 'logger',
|
|
199
|
-
version: '1.0.0',
|
|
200
|
-
enabled: true,
|
|
201
|
-
dependencies: [],
|
|
202
|
-
config: {
|
|
203
|
-
level: loggerConfig.level,
|
|
204
|
-
format: 'pretty'
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
name: 'vite',
|
|
209
|
-
version: '1.0.0',
|
|
210
|
-
enabled: true,
|
|
211
|
-
dependencies: [],
|
|
212
|
-
config: {
|
|
213
|
-
port: 5173,
|
|
214
|
-
hmr: true
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
name: 'static-files',
|
|
219
|
-
version: '1.0.0',
|
|
220
|
-
enabled: true,
|
|
221
|
-
dependencies: [],
|
|
222
|
-
config: {
|
|
223
|
-
publicPath: 'public',
|
|
224
|
-
uploadsPath: 'uploads'
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
name: 'live-components',
|
|
229
|
-
version: '1.0.0',
|
|
230
|
-
enabled: true,
|
|
231
|
-
dependencies: [],
|
|
232
|
-
config: {
|
|
233
|
-
websocketPath: '/api/live/ws',
|
|
234
|
-
autoDiscovery: true
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
name: 'swagger',
|
|
239
|
-
version: '1.0.0',
|
|
240
|
-
enabled: true,
|
|
241
|
-
dependencies: [],
|
|
242
|
-
config: {
|
|
243
|
-
path: '/swagger',
|
|
244
|
-
title: 'FluxStack API'
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
]
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Get runtime configuration
|
|
251
|
-
private getRuntimeConfiguration() {
|
|
252
|
-
return {
|
|
253
|
-
nodeVersion: systemRuntimeInfo.nodeVersion,
|
|
254
|
-
bunVersion: systemRuntimeInfo.bunVersion,
|
|
255
|
-
platform: systemRuntimeInfo.platform,
|
|
256
|
-
architecture: systemRuntimeInfo.architecture,
|
|
257
|
-
cpuCount: systemRuntimeInfo.cpuCount,
|
|
258
|
-
totalMemory: systemRuntimeInfo.totalMemory,
|
|
259
|
-
workingDirectory: systemRuntimeInfo.workingDirectory,
|
|
260
|
-
executablePath: systemRuntimeInfo.executablePath
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Get Live Components configuration
|
|
265
|
-
private getLiveComponentsConfiguration() {
|
|
266
|
-
return {
|
|
267
|
-
enabled: true,
|
|
268
|
-
autoDiscovery: true,
|
|
269
|
-
websocketPath: '/api/live/ws',
|
|
270
|
-
signatureSecret: '***hidden***',
|
|
271
|
-
maxConnections: 1000,
|
|
272
|
-
timeout: 30000
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// Get Vite configuration
|
|
277
|
-
private getViteConfiguration() {
|
|
278
|
-
return {
|
|
279
|
-
enabled: true,
|
|
280
|
-
port: 5173,
|
|
281
|
-
host: 'localhost',
|
|
282
|
-
hmr: true,
|
|
283
|
-
publicDir: 'public',
|
|
284
|
-
buildDir: 'dist'
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// Get Static Files configuration
|
|
289
|
-
private getStaticFilesConfiguration() {
|
|
290
|
-
return {
|
|
291
|
-
enabled: true,
|
|
292
|
-
publicPath: 'public',
|
|
293
|
-
uploadsPath: 'uploads',
|
|
294
|
-
maxFileSize: 10 * 1024 * 1024, // 10MB
|
|
295
|
-
allowedExtensions: ['.jpg', '.png', '.gif', '.pdf', '.txt', '.json']
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Get Swagger configuration
|
|
300
|
-
private getSwaggerConfiguration() {
|
|
301
|
-
return {
|
|
302
|
-
enabled: true,
|
|
303
|
-
title: 'FluxStack API',
|
|
304
|
-
version: '1.0.0',
|
|
305
|
-
description: 'Modern Full-Stack TypeScript Framework API',
|
|
306
|
-
path: '/swagger'
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// Get Security configuration
|
|
311
|
-
private getSecurityConfiguration() {
|
|
312
|
-
return {
|
|
313
|
-
cors: {
|
|
314
|
-
enabled: true,
|
|
315
|
-
origins: ['http://localhost:5173', 'http://localhost:3000'],
|
|
316
|
-
credentials: true
|
|
317
|
-
},
|
|
318
|
-
rateLimit: {
|
|
319
|
-
enabled: false,
|
|
320
|
-
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
321
|
-
maxRequests: 100
|
|
322
|
-
},
|
|
323
|
-
helmet: {
|
|
324
|
-
enabled: false,
|
|
325
|
-
options: {}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Get Performance configuration
|
|
331
|
-
private getPerformanceConfiguration() {
|
|
332
|
-
return {
|
|
333
|
-
compression: true,
|
|
334
|
-
cache: {
|
|
335
|
-
enabled: false,
|
|
336
|
-
maxAge: 3600,
|
|
337
|
-
strategy: 'memory'
|
|
338
|
-
},
|
|
339
|
-
clustering: {
|
|
340
|
-
enabled: false,
|
|
341
|
-
workers: 1
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// Get Database configuration
|
|
347
|
-
private getDatabaseConfiguration() {
|
|
348
|
-
return {
|
|
349
|
-
enabled: false,
|
|
350
|
-
type: undefined,
|
|
351
|
-
host: undefined,
|
|
352
|
-
port: undefined,
|
|
353
|
-
name: undefined,
|
|
354
|
-
ssl: false
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// Get Logging configuration
|
|
359
|
-
private getLoggingConfiguration() {
|
|
360
|
-
return {
|
|
361
|
-
level: loggerConfig.level as 'debug' | 'info' | 'warn' | 'error',
|
|
362
|
-
format: 'pretty' as 'json' | 'pretty' | 'compact',
|
|
363
|
-
file: {
|
|
364
|
-
enabled: loggerConfig.logToFile,
|
|
365
|
-
path: loggerConfig.logToFile ? 'logs/app.log' : undefined,
|
|
366
|
-
maxSize: loggerConfig.maxSize,
|
|
367
|
-
maxFiles: parseInt(loggerConfig.maxFiles) || undefined
|
|
368
|
-
},
|
|
369
|
-
console: {
|
|
370
|
-
enabled: true,
|
|
371
|
-
colors: loggerConfig.enableColors
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// Get Advanced configuration
|
|
377
|
-
private getAdvancedConfiguration() {
|
|
378
|
-
return {
|
|
379
|
-
hotReload: true,
|
|
380
|
-
typeChecking: true,
|
|
381
|
-
sourceMap: true,
|
|
382
|
-
minification: false,
|
|
383
|
-
bundleAnalyzer: false
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Refresh all configuration
|
|
388
|
-
async refreshConfiguration() {
|
|
389
|
-
this.setState({
|
|
390
|
-
plugins: this.getPluginConfiguration(),
|
|
391
|
-
runtime: this.getRuntimeConfiguration(),
|
|
392
|
-
liveComponents: this.getLiveComponentsConfiguration(),
|
|
393
|
-
vite: this.getViteConfiguration(),
|
|
394
|
-
staticFiles: this.getStaticFilesConfiguration(),
|
|
395
|
-
swagger: this.getSwaggerConfiguration(),
|
|
396
|
-
security: this.getSecurityConfiguration(),
|
|
397
|
-
performance: this.getPerformanceConfiguration(),
|
|
398
|
-
database: this.getDatabaseConfiguration(),
|
|
399
|
-
logging: this.getLoggingConfiguration(),
|
|
400
|
-
advanced: this.getAdvancedConfiguration(),
|
|
401
|
-
lastUpdated: Date.now()
|
|
402
|
-
})
|
|
403
|
-
|
|
404
|
-
this.emit('CONFIGURATION_REFRESHED', {
|
|
405
|
-
timestamp: Date.now()
|
|
406
|
-
})
|
|
407
|
-
|
|
408
|
-
console.log('🔄 FluxStackConfig: Configuration refreshed')
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// Update specific configuration section
|
|
412
|
-
async updateConfiguration(data: { section: string; config: Record<string, any> }) {
|
|
413
|
-
const { section, config } = data
|
|
414
|
-
|
|
415
|
-
if (!this.state[section as keyof FluxStackConfigState]) {
|
|
416
|
-
throw new Error(`Invalid configuration section: ${section}`)
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
const currentSection = this.state[section as keyof FluxStackConfigState]
|
|
420
|
-
const updatedSection = typeof currentSection === 'object' && currentSection !== null
|
|
421
|
-
? { ...currentSection as object, ...config }
|
|
422
|
-
: config
|
|
423
|
-
|
|
424
|
-
this.setState({
|
|
425
|
-
[section]: updatedSection,
|
|
426
|
-
lastUpdated: Date.now()
|
|
427
|
-
} as Partial<FluxStackConfigState>)
|
|
428
|
-
|
|
429
|
-
this.emit('CONFIGURATION_UPDATED', {
|
|
430
|
-
section,
|
|
431
|
-
config,
|
|
432
|
-
timestamp: Date.now()
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
console.log(`⚙️ FluxStackConfig: Updated section '${section}'`, config)
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// Get environment variables
|
|
439
|
-
async getEnvironmentVariables() {
|
|
440
|
-
const envVars = {
|
|
441
|
-
NODE_ENV: appConfig.env,
|
|
442
|
-
PORT: serverConfig.port.toString(),
|
|
443
|
-
HOST: serverConfig.host,
|
|
444
|
-
LOG_LEVEL: loggerConfig.level,
|
|
445
|
-
// Add other non-sensitive env vars from system config
|
|
446
|
-
PWD: systemConfig.pwd || undefined,
|
|
447
|
-
PATH: systemConfig.path ? '***truncated***' : undefined,
|
|
448
|
-
USER: systemConfig.currentUser,
|
|
449
|
-
HOME: systemConfig.homeDirectory || undefined
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
this.emit('ENVIRONMENT_VARIABLES_REQUESTED', {
|
|
453
|
-
count: Object.keys(envVars).length,
|
|
454
|
-
timestamp: Date.now()
|
|
455
|
-
})
|
|
456
|
-
|
|
457
|
-
return envVars
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// Export configuration as JSON
|
|
461
|
-
async exportConfiguration() {
|
|
462
|
-
const config = {
|
|
463
|
-
...this.state,
|
|
464
|
-
exportedAt: new Date().toISOString(),
|
|
465
|
-
exportedBy: 'FluxStack Configuration Manager'
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
this.emit('CONFIGURATION_EXPORTED', {
|
|
469
|
-
timestamp: Date.now()
|
|
470
|
-
})
|
|
471
|
-
|
|
472
|
-
console.log('📤 FluxStackConfig: Configuration exported')
|
|
473
|
-
return config
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// Validate configuration
|
|
477
|
-
async validateConfiguration() {
|
|
478
|
-
const issues: string[] = []
|
|
479
|
-
|
|
480
|
-
// Check port conflicts
|
|
481
|
-
if (this.state.port === this.state.vite.port) {
|
|
482
|
-
issues.push('Server port conflicts with Vite port')
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// Check memory usage
|
|
486
|
-
if (this.state.runtime.totalMemory < 2) {
|
|
487
|
-
issues.push('Low system memory (< 2GB)')
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// Check required directories
|
|
491
|
-
if (!this.state.staticFiles.publicPath) {
|
|
492
|
-
issues.push('Public directory not configured')
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
const result = {
|
|
496
|
-
valid: issues.length === 0,
|
|
497
|
-
issues,
|
|
498
|
-
timestamp: Date.now()
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
this.emit('CONFIGURATION_VALIDATED', result)
|
|
502
|
-
|
|
503
|
-
console.log(`✅ FluxStackConfig: Validation ${result.valid ? 'passed' : 'failed'}`,
|
|
504
|
-
{ issues: issues.length })
|
|
505
|
-
|
|
506
|
-
return result
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
// Get system health based on configuration
|
|
510
|
-
async getSystemHealth() {
|
|
511
|
-
const health = {
|
|
512
|
-
status: 'healthy' as 'healthy' | 'warning' | 'critical',
|
|
513
|
-
checks: {
|
|
514
|
-
memory: this.state.runtime.totalMemory > 1,
|
|
515
|
-
plugins: this.state.plugins.every(p => p.enabled),
|
|
516
|
-
liveComponents: this.state.liveComponents.enabled,
|
|
517
|
-
vite: this.state.vite.enabled,
|
|
518
|
-
swagger: this.state.swagger.enabled
|
|
519
|
-
},
|
|
520
|
-
score: 0,
|
|
521
|
-
timestamp: Date.now()
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
const passed = Object.values(health.checks).filter(Boolean).length
|
|
525
|
-
health.score = Math.round((passed / Object.keys(health.checks).length) * 100)
|
|
526
|
-
|
|
527
|
-
if (health.score < 60) health.status = 'critical'
|
|
528
|
-
else if (health.score < 80) health.status = 'warning'
|
|
529
|
-
|
|
530
|
-
this.emit('SYSTEM_HEALTH_CHECKED', health)
|
|
531
|
-
|
|
532
|
-
return health
|
|
533
|
-
}
|
|
534
|
-
}
|