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
|
@@ -54,7 +54,7 @@ export function createMiddleware<TContext = any>(
|
|
|
54
54
|
return new Elysia({ name }).derive(handler as any)
|
|
55
55
|
} else {
|
|
56
56
|
// Blocking: use onBeforeHandle() - can stop execution by returning a response
|
|
57
|
-
return new Elysia({ name }).onBeforeHandle(handler as any)
|
|
57
|
+
return new Elysia({ name }).onBeforeHandle(handler as any)
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -109,7 +109,6 @@ export function createGuard<TContext = any>(options: {
|
|
|
109
109
|
return options.onFail((ctx as any).set, ctx as TContext)
|
|
110
110
|
}
|
|
111
111
|
})
|
|
112
|
-
.as('plugin')
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
/**
|
|
@@ -182,7 +181,6 @@ export function createRateLimit(options: {
|
|
|
182
181
|
requests.set(key, { count: 1, resetTime: now + windowMs })
|
|
183
182
|
}
|
|
184
183
|
})
|
|
185
|
-
.as('plugin')
|
|
186
184
|
}
|
|
187
185
|
|
|
188
186
|
/**
|
|
@@ -208,7 +206,7 @@ export function composeMiddleware(options: {
|
|
|
208
206
|
composed = composed.use(middleware)
|
|
209
207
|
}
|
|
210
208
|
|
|
211
|
-
return composed
|
|
209
|
+
return composed
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
/**
|
|
@@ -224,4 +222,4 @@ export function isProduction() {
|
|
|
224
222
|
|
|
225
223
|
export function isTest() {
|
|
226
224
|
return process.env.NODE_ENV === 'test'
|
|
227
|
-
}
|
|
225
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { existsSync, statSync } from 'fs'
|
|
4
4
|
import { join, extname, resolve } from 'path'
|
|
5
|
-
import type {
|
|
5
|
+
import type { FluxStack, PluginContext } from '../plugins/types'
|
|
6
6
|
|
|
7
7
|
export interface StaticFilesConfig {
|
|
8
8
|
publicDir?: string // Default: 'public'
|
|
@@ -144,6 +144,7 @@ export class ProjectCreator {
|
|
|
144
144
|
dev: "bun run core/cli/index.ts dev",
|
|
145
145
|
"dev:frontend": "bun run core/cli/index.ts frontend",
|
|
146
146
|
"dev:backend": "bun run core/cli/index.ts backend",
|
|
147
|
+
"sync-version": "bun run core/utils/sync-version.ts",
|
|
147
148
|
build: "bun run core/cli/index.ts build",
|
|
148
149
|
"build:frontend": "bun run core/cli/index.ts build:frontend",
|
|
149
150
|
"build:backend": "bun run core/cli/index.ts build:backend",
|
package/core/types/index.ts
CHANGED
package/core/types/plugin.ts
CHANGED
package/core/types/types.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// 🔥 FluxStack Live Components - Shared Types
|
|
2
2
|
|
|
3
3
|
export interface LiveMessage {
|
|
4
|
-
type: 'COMPONENT_MOUNT' | 'COMPONENT_UNMOUNT' |
|
|
4
|
+
type: 'COMPONENT_MOUNT' | 'COMPONENT_UNMOUNT' |
|
|
5
|
+
'COMPONENT_REHYDRATE' | 'COMPONENT_ACTION' | 'CALL_ACTION' |
|
|
6
|
+
'ACTION_RESPONSE' | 'PROPERTY_UPDATE' | 'STATE_UPDATE' | 'STATE_REHYDRATED' |
|
|
7
|
+
'ERROR' | 'BROADCAST' | 'FILE_UPLOAD_START' | 'FILE_UPLOAD_CHUNK' | 'FILE_UPLOAD_COMPLETE' |
|
|
8
|
+
'COMPONENT_PING' | 'COMPONENT_PONG'
|
|
5
9
|
componentId: string
|
|
6
10
|
action?: string
|
|
7
11
|
property?: string
|
|
@@ -65,7 +69,7 @@ export interface WebSocketMessage {
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
export interface WebSocketResponse {
|
|
68
|
-
type: 'MESSAGE_RESPONSE' | 'CONNECTION_ESTABLISHED' | 'ERROR' | 'BROADCAST' | 'ACTION_RESPONSE' | 'COMPONENT_MOUNTED' | 'COMPONENT_REHYDRATED' | 'STATE_UPDATE' | 'STATE_REHYDRATED' | 'FILE_UPLOAD_PROGRESS' | 'FILE_UPLOAD_COMPLETE' | 'FILE_UPLOAD_ERROR' | 'FILE_UPLOAD_START_RESPONSE'
|
|
72
|
+
type: 'MESSAGE_RESPONSE' | 'CONNECTION_ESTABLISHED' | 'ERROR' | 'BROADCAST' | 'ACTION_RESPONSE' | 'COMPONENT_MOUNTED' | 'COMPONENT_REHYDRATED' | 'STATE_UPDATE' | 'STATE_REHYDRATED' | 'FILE_UPLOAD_PROGRESS' | 'FILE_UPLOAD_COMPLETE' | 'FILE_UPLOAD_ERROR' | 'FILE_UPLOAD_START_RESPONSE' | 'COMPONENT_PONG'
|
|
69
73
|
originalType?: string
|
|
70
74
|
componentId?: string
|
|
71
75
|
success?: boolean
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Generates unique colors for each module
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import chalk from 'chalk'
|
|
6
|
+
import chalk, { type ChalkInstance } from 'chalk'
|
|
7
7
|
|
|
8
|
-
// Cache for module colors
|
|
9
|
-
const moduleColors = new Map<string,
|
|
8
|
+
// Cache for module colors
|
|
9
|
+
const moduleColors = new Map<string, ChalkInstance>()
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Pre-defined colors for common modules
|
|
@@ -55,7 +55,7 @@ export const LEVEL_COLORS = {
|
|
|
55
55
|
/**
|
|
56
56
|
* Generate a unique color for a module based on its name
|
|
57
57
|
*/
|
|
58
|
-
export function getColorForModule(moduleName: string):
|
|
58
|
+
export function getColorForModule(moduleName: string): ChalkInstance {
|
|
59
59
|
// Check cache first
|
|
60
60
|
if (moduleColors.has(moduleName)) {
|
|
61
61
|
return moduleColors.get(moduleName)!
|
|
@@ -125,12 +125,45 @@ export function SECTION(sectionName: string, callback: () => void): void {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
|
-
* HTTP request logging
|
|
128
|
+
* HTTP request logging with colors and formatting
|
|
129
129
|
*/
|
|
130
130
|
export function request(method: string, path: string, status?: number, duration?: number): void {
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
|
|
131
|
+
const { file: callerFile } = getCallerInfo()
|
|
132
|
+
const logger = getLoggerForModule(callerFile)
|
|
133
|
+
|
|
134
|
+
// Color based on HTTP status
|
|
135
|
+
let statusColor = chalk.gray
|
|
136
|
+
if (status) {
|
|
137
|
+
if (status >= 500) statusColor = chalk.red.bold // Server errors
|
|
138
|
+
else if (status >= 400) statusColor = chalk.yellow // Client errors
|
|
139
|
+
else if (status >= 300) statusColor = chalk.cyan // Redirects
|
|
140
|
+
else if (status >= 200) statusColor = chalk.green // Success
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Color for HTTP method
|
|
144
|
+
let methodColor = chalk.blue
|
|
145
|
+
if (method === 'POST') methodColor = chalk.green
|
|
146
|
+
else if (method === 'PUT') methodColor = chalk.yellow
|
|
147
|
+
else if (method === 'PATCH') methodColor = chalk.magenta
|
|
148
|
+
else if (method === 'DELETE') methodColor = chalk.red
|
|
149
|
+
|
|
150
|
+
// Format duration with color (warn if slow)
|
|
151
|
+
let durationStr = ''
|
|
152
|
+
if (duration !== undefined) {
|
|
153
|
+
const durationColor = duration > 1000 ? chalk.red : duration > 500 ? chalk.yellow : chalk.gray
|
|
154
|
+
durationStr = ` ${durationColor(`(${duration}ms)`)}`
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Build log message
|
|
158
|
+
const methodStr = methodColor(method.padEnd(7))
|
|
159
|
+
const pathStr = chalk.white(path.padEnd(30))
|
|
160
|
+
const statusStr = status ? `→ ${statusColor(status.toString())}` : ''
|
|
161
|
+
|
|
162
|
+
const message = `${methodStr} ${pathStr} ${statusStr}${durationStr}`
|
|
163
|
+
|
|
164
|
+
// Use appropriate log level based on status
|
|
165
|
+
const level = status && status >= 500 ? 'error' : status && status >= 400 ? 'warn' : 'info'
|
|
166
|
+
logger.log({ level, message })
|
|
134
167
|
}
|
|
135
168
|
|
|
136
169
|
/**
|
|
@@ -33,7 +33,7 @@ function createConsoleFormat() {
|
|
|
33
33
|
function createFileFormat() {
|
|
34
34
|
return winston.format.printf(({ timestamp, level, message }) => {
|
|
35
35
|
// Remove ANSI color codes
|
|
36
|
-
const cleanMessage = message.replace(/\u001b\[.*?m/g, '')
|
|
36
|
+
const cleanMessage = String(message).replace(/\u001b\[.*?m/g, '')
|
|
37
37
|
return `[${timestamp}] [${level.toUpperCase()}]: ${cleanMessage}`
|
|
38
38
|
})
|
|
39
39
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Version Synchronization Utility
|
|
5
|
+
* Ensures version consistency between package.json and version.ts
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { readFileSync, writeFileSync } from 'fs'
|
|
9
|
+
import { join } from 'path'
|
|
10
|
+
|
|
11
|
+
interface PackageJson {
|
|
12
|
+
version: string
|
|
13
|
+
[key: string]: any
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Read version from package.json
|
|
18
|
+
*/
|
|
19
|
+
function getPackageVersion(): string {
|
|
20
|
+
const packagePath = join(process.cwd(), 'package.json')
|
|
21
|
+
const packageContent = readFileSync(packagePath, 'utf-8')
|
|
22
|
+
const packageJson: PackageJson = JSON.parse(packageContent)
|
|
23
|
+
return packageJson.version
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Update version.ts with the version from package.json
|
|
28
|
+
*/
|
|
29
|
+
function updateVersionFile(version: string, silent = false): void {
|
|
30
|
+
const versionPath = join(process.cwd(), 'core/utils/version.ts')
|
|
31
|
+
const versionContent = `/**
|
|
32
|
+
* FluxStack Framework Version
|
|
33
|
+
* Single source of truth for version number
|
|
34
|
+
* Auto-synced with package.json
|
|
35
|
+
*/
|
|
36
|
+
export const FLUXSTACK_VERSION = '${version}'
|
|
37
|
+
`
|
|
38
|
+
writeFileSync(versionPath, versionContent)
|
|
39
|
+
if (!silent) {
|
|
40
|
+
console.log(`✅ Updated version.ts to v${version}`)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Main sync function
|
|
46
|
+
*/
|
|
47
|
+
function syncVersion(silent = false): void {
|
|
48
|
+
try {
|
|
49
|
+
const packageVersion = getPackageVersion()
|
|
50
|
+
updateVersionFile(packageVersion, silent)
|
|
51
|
+
if (!silent) {
|
|
52
|
+
console.log(`🔄 Version synchronized: v${packageVersion}`)
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (!silent) {
|
|
56
|
+
console.error('❌ Failed to sync version:', error)
|
|
57
|
+
}
|
|
58
|
+
process.exit(1)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Run if called directly
|
|
63
|
+
if (import.meta.main) {
|
|
64
|
+
syncVersion()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { syncVersion, getPackageVersion }
|
package/core/utils/version.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FluxStack Framework Version
|
|
3
|
-
* Single source of truth for version number
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* FluxStack Framework Version
|
|
3
|
+
* Single source of truth for version number
|
|
4
|
+
* Auto-synced with package.json
|
|
5
|
+
*/
|
|
6
|
+
export const FLUXSTACK_VERSION = '1.7.3'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-fluxstack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "⚡ Revolutionary full-stack TypeScript framework with Declarative Config System, Elysia + React + Bun",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"dev:frontend": "bun run core/cli/index.ts frontend",
|
|
29
29
|
"dev:backend": "bun run core/cli/index.ts backend",
|
|
30
30
|
"dev:coordinated": "concurrently --prefix {name} --names BACKEND,VITE --prefix-colors blue,green --kill-others-on-fail \"bun --watch app/server/index.ts\" \"vite --config vite.config.ts\"",
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
"sync-version": "bun run core/utils/sync-version.ts",
|
|
32
33
|
"build": "cross-env NODE_ENV=production bun run core/cli/index.ts build",
|
|
33
34
|
"build:frontend": "vite build --config vite.config.ts --emptyOutDir",
|
|
34
35
|
"build:backend": "bun run core/cli/index.ts build:backend",
|
package/vite.config.ts
CHANGED
|
@@ -43,11 +43,19 @@ export default defineConfig({
|
|
|
43
43
|
server: {
|
|
44
44
|
port: 5173,
|
|
45
45
|
host: true,
|
|
46
|
+
// Configuração explícita do HMR para evitar conflito com WebSocket do backend
|
|
47
|
+
hmr: {
|
|
48
|
+
protocol: 'ws',
|
|
49
|
+
host: 'localhost',
|
|
50
|
+
port: 5173,
|
|
51
|
+
clientPort: 5173,
|
|
52
|
+
},
|
|
46
53
|
proxy: {
|
|
47
54
|
'/api': {
|
|
48
55
|
target: 'http://localhost:3000',
|
|
49
56
|
changeOrigin: true,
|
|
50
57
|
secure: false,
|
|
58
|
+
ws: true, // Habilita proxy WebSocket para live components
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
},
|
package/.dockerignore
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Dependencies
|
|
2
|
-
node_modules/
|
|
3
|
-
*/node_modules/
|
|
4
|
-
|
|
5
|
-
# Build outputs (will be generated in container)
|
|
6
|
-
dist/
|
|
7
|
-
build/
|
|
8
|
-
.next/
|
|
9
|
-
|
|
10
|
-
# Development files
|
|
11
|
-
.env.local
|
|
12
|
-
.env.development
|
|
13
|
-
|
|
14
|
-
# IDE files
|
|
15
|
-
.vscode/
|
|
16
|
-
.idea/
|
|
17
|
-
*.swp
|
|
18
|
-
*.swo
|
|
19
|
-
|
|
20
|
-
# OS files
|
|
21
|
-
.DS_Store
|
|
22
|
-
Thumbs.db
|
|
23
|
-
|
|
24
|
-
# Logs
|
|
25
|
-
*.log
|
|
26
|
-
logs/
|
|
27
|
-
|
|
28
|
-
# Runtime
|
|
29
|
-
.tmp/
|
|
30
|
-
.cache/
|
|
31
|
-
|
|
32
|
-
# Git
|
|
33
|
-
.git/
|
|
34
|
-
.gitignore
|
|
35
|
-
|
|
36
|
-
# Testing
|
|
37
|
-
coverage/
|
|
38
|
-
.nyc_output
|
|
39
|
-
|
|
40
|
-
# Context AI (not needed in production)
|
|
41
|
-
context_ai/
|
|
42
|
-
|
|
43
|
-
# Tests (not needed in production)
|
|
44
|
-
tests/
|
|
45
|
-
*.test.*
|
|
46
|
-
*.spec.*
|
|
47
|
-
|
|
48
|
-
# Documentation
|
|
49
|
-
*.md
|
|
50
|
-
!README.md
|