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
package/core/build/optimizer.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { readFileSync, writeFileSync, statSync, readdirSync } from "fs"
|
|
|
2
2
|
import { join, extname } from "path"
|
|
3
3
|
import { gzipSync } from "zlib"
|
|
4
4
|
import type { OptimizationConfig, OptimizationResult } from "../types/build"
|
|
5
|
+
import { buildLogger } from "../utils/build-logger"
|
|
5
6
|
|
|
6
7
|
export interface OptimizerConfig {
|
|
7
8
|
treeshake: boolean
|
|
@@ -19,8 +20,8 @@ export class Optimizer {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
async optimize(buildPath: string): Promise<OptimizationResult> {
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
buildLogger.section('Build Optimization', '🔧')
|
|
24
|
+
|
|
24
25
|
const startTime = Date.now()
|
|
25
26
|
const results: OptimizationResult = {
|
|
26
27
|
success: true,
|
|
@@ -34,6 +35,7 @@ export class Optimizer {
|
|
|
34
35
|
try {
|
|
35
36
|
// Get original size
|
|
36
37
|
results.originalSize = await this.calculateDirectorySize(buildPath)
|
|
38
|
+
buildLogger.step(`Original size: ${buildLogger.formatSize(results.originalSize)}`)
|
|
37
39
|
|
|
38
40
|
// Apply optimizations (minification removed for compatibility)
|
|
39
41
|
|
|
@@ -55,23 +57,40 @@ export class Optimizer {
|
|
|
55
57
|
|
|
56
58
|
// Calculate final size and compression ratio
|
|
57
59
|
results.optimizedSize = await this.calculateDirectorySize(buildPath)
|
|
58
|
-
results.compressionRatio = results.originalSize > 0
|
|
59
|
-
? ((results.originalSize - results.optimizedSize) / results.originalSize) * 100
|
|
60
|
+
results.compressionRatio = results.originalSize > 0
|
|
61
|
+
? ((results.originalSize - results.optimizedSize) / results.originalSize) * 100
|
|
60
62
|
: 0
|
|
61
63
|
|
|
62
64
|
results.duration = Date.now() - startTime
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
buildLogger.success(`Optimization completed in ${buildLogger.formatDuration(results.duration)}`)
|
|
67
|
+
|
|
68
|
+
// Create optimization summary table
|
|
69
|
+
const optimizationData = results.optimizations.map(opt => ({
|
|
70
|
+
type: opt.type,
|
|
71
|
+
description: opt.description,
|
|
72
|
+
saved: buildLogger.formatSize(opt.sizeSaved)
|
|
73
|
+
}))
|
|
74
|
+
|
|
75
|
+
if (optimizationData.length > 0) {
|
|
76
|
+
buildLogger.table(
|
|
77
|
+
[
|
|
78
|
+
{ header: 'Optimization', key: 'type', width: 20, align: 'left', color: 'cyan' },
|
|
79
|
+
{ header: 'Description', key: 'description', width: 35, align: 'left' },
|
|
80
|
+
{ header: 'Size Saved', key: 'saved', width: 12, align: 'right', color: 'green' }
|
|
81
|
+
],
|
|
82
|
+
optimizationData
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
67
86
|
return results
|
|
68
87
|
|
|
69
88
|
} catch (error) {
|
|
70
89
|
results.success = false
|
|
71
90
|
results.duration = Date.now() - startTime
|
|
72
91
|
results.error = error instanceof Error ? error.message : "Unknown optimization error"
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
|
|
93
|
+
buildLogger.error(`Optimization failed: ${results.error}`)
|
|
75
94
|
return results
|
|
76
95
|
}
|
|
77
96
|
}
|
|
@@ -79,8 +98,8 @@ export class Optimizer {
|
|
|
79
98
|
// Minification methods removed for compatibility with Bun bundler
|
|
80
99
|
|
|
81
100
|
private async compressAssets(buildPath: string, results: OptimizationResult): Promise<void> {
|
|
82
|
-
|
|
83
|
-
|
|
101
|
+
buildLogger.step("Compressing assets...")
|
|
102
|
+
|
|
84
103
|
const files = this.getFilesRecursively(buildPath)
|
|
85
104
|
let compressedCount = 0
|
|
86
105
|
|
|
@@ -98,11 +117,12 @@ export class Optimizer {
|
|
|
98
117
|
compressedCount++
|
|
99
118
|
}
|
|
100
119
|
} catch (error) {
|
|
101
|
-
|
|
120
|
+
// Silently skip files that can't be compressed
|
|
102
121
|
}
|
|
103
122
|
}
|
|
104
123
|
}
|
|
105
124
|
|
|
125
|
+
buildLogger.success(`Compressed ${compressedCount} files`)
|
|
106
126
|
results.optimizations.push({
|
|
107
127
|
type: 'compression',
|
|
108
128
|
description: `Created gzip versions for ${compressedCount} files`,
|
|
@@ -111,8 +131,8 @@ export class Optimizer {
|
|
|
111
131
|
}
|
|
112
132
|
|
|
113
133
|
private async removeUnusedCSS(buildPath: string, results: OptimizationResult): Promise<void> {
|
|
114
|
-
|
|
115
|
-
|
|
134
|
+
buildLogger.step("Analyzing CSS...")
|
|
135
|
+
|
|
116
136
|
// This is a placeholder - real implementation would use PurgeCSS or similar
|
|
117
137
|
results.optimizations.push({
|
|
118
138
|
type: 'css-purging',
|
|
@@ -122,8 +142,8 @@ export class Optimizer {
|
|
|
122
142
|
}
|
|
123
143
|
|
|
124
144
|
private async optimizeImages(buildPath: string, results: OptimizationResult): Promise<void> {
|
|
125
|
-
|
|
126
|
-
|
|
145
|
+
buildLogger.step("Optimizing images...")
|
|
146
|
+
|
|
127
147
|
// This is a placeholder - real implementation would use imagemin or similar
|
|
128
148
|
results.optimizations.push({
|
|
129
149
|
type: 'image-optimization',
|
|
@@ -133,7 +153,7 @@ export class Optimizer {
|
|
|
133
153
|
}
|
|
134
154
|
|
|
135
155
|
private async analyzeBundles(buildPath: string, results: OptimizationResult): Promise<void> {
|
|
136
|
-
|
|
156
|
+
buildLogger.step("Analyzing bundles...")
|
|
137
157
|
|
|
138
158
|
const files = this.getFilesRecursively(buildPath)
|
|
139
159
|
const jsFiles = files.filter(f => extname(f) === '.js')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CliCommand, CliContext, CliArgument, CliOption } from "../plugins/types"
|
|
2
|
-
import { getConfigSync } from "
|
|
3
|
-
import { logger } from "
|
|
2
|
+
import { getConfigSync } from "@/core/config"
|
|
3
|
+
import { logger } from "@/core/utils/logger"
|
|
4
4
|
import { createTimer, formatBytes, isProduction, isDevelopment } from "../utils/helpers"
|
|
5
5
|
|
|
6
6
|
export class CliCommandRegistry {
|
|
@@ -10,20 +10,10 @@ export class CliCommandRegistry {
|
|
|
10
10
|
|
|
11
11
|
constructor() {
|
|
12
12
|
const config = getConfigSync()
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
this.context = {
|
|
15
15
|
config,
|
|
16
|
-
logger:
|
|
17
|
-
debug: (message: string, meta?: unknown) => logger.debug(message, meta),
|
|
18
|
-
info: (message: string, meta?: unknown) => logger.info(message, meta),
|
|
19
|
-
warn: (message: string, meta?: unknown) => logger.warn(message, meta),
|
|
20
|
-
error: (message: string, meta?: unknown) => logger.error(message, meta),
|
|
21
|
-
child: (context: Record<string, unknown>) => logger,
|
|
22
|
-
time: (label: string) => logger.time(label),
|
|
23
|
-
timeEnd: (label: string) => logger.timeEnd(label),
|
|
24
|
-
request: (method: string, path: string, status?: number, duration?: number) =>
|
|
25
|
-
logger.request(method, path, status, duration)
|
|
26
|
-
},
|
|
16
|
+
logger: logger as any,
|
|
27
17
|
utils: {
|
|
28
18
|
createTimer,
|
|
29
19
|
formatBytes,
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { Command } from 'commander'
|
|
6
6
|
import chalk from 'chalk'
|
|
7
|
-
import { PluginDependencyManager } from '
|
|
8
|
-
import { PluginRegistry } from '
|
|
7
|
+
import { PluginDependencyManager } from '@/core/plugins/dependency-manager'
|
|
8
|
+
import { PluginRegistry } from '@/core/plugins/registry'
|
|
9
9
|
import { existsSync, readFileSync } from 'fs'
|
|
10
10
|
import { join } from 'path'
|
|
11
11
|
|
|
@@ -32,11 +32,11 @@ function createInstallCommand(): Command {
|
|
|
32
32
|
const dependencyManager = new PluginDependencyManager({
|
|
33
33
|
autoInstall: !options.dryRun,
|
|
34
34
|
packageManager: options.packageManager,
|
|
35
|
-
logger: createConsoleLogger()
|
|
35
|
+
logger: createConsoleLogger() as any as any
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
const registry = new PluginRegistry({
|
|
39
|
-
logger: createConsoleLogger()
|
|
39
|
+
logger: createConsoleLogger() as any as any
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
// Descobrir plugins
|
|
@@ -104,7 +104,7 @@ function createListCommand(): Command {
|
|
|
104
104
|
|
|
105
105
|
try {
|
|
106
106
|
const registry = new PluginRegistry({
|
|
107
|
-
logger: createConsoleLogger()
|
|
107
|
+
logger: createConsoleLogger() as any
|
|
108
108
|
})
|
|
109
109
|
|
|
110
110
|
const results = await registry.discoverPlugins({
|
|
@@ -113,7 +113,7 @@ function createListCommand(): Command {
|
|
|
113
113
|
|
|
114
114
|
const dependencyManager = new PluginDependencyManager({
|
|
115
115
|
autoInstall: false,
|
|
116
|
-
logger: createConsoleLogger()
|
|
116
|
+
logger: createConsoleLogger() as any
|
|
117
117
|
})
|
|
118
118
|
|
|
119
119
|
for (const result of results) {
|
|
@@ -162,7 +162,7 @@ function createCheckCommand(): Command {
|
|
|
162
162
|
|
|
163
163
|
try {
|
|
164
164
|
const registry = new PluginRegistry({
|
|
165
|
-
logger: createConsoleLogger()
|
|
165
|
+
logger: createConsoleLogger() as any
|
|
166
166
|
})
|
|
167
167
|
|
|
168
168
|
const results = await registry.discoverPlugins({
|
|
@@ -171,7 +171,7 @@ function createCheckCommand(): Command {
|
|
|
171
171
|
|
|
172
172
|
const dependencyManager = new PluginDependencyManager({
|
|
173
173
|
autoInstall: false,
|
|
174
|
-
logger: createConsoleLogger()
|
|
174
|
+
logger: createConsoleLogger() as any
|
|
175
175
|
})
|
|
176
176
|
|
|
177
177
|
const resolutions = []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Generator } from "./index
|
|
2
|
-
import type { GeneratorContext, GeneratorOptions, Template } from "./types
|
|
3
|
-
import { templateEngine } from "./template-engine
|
|
1
|
+
import type { Generator } from "./index"
|
|
2
|
+
import type { GeneratorContext, GeneratorOptions, Template } from "./types"
|
|
3
|
+
import { templateEngine } from "./template-engine"
|
|
4
4
|
|
|
5
5
|
export class ComponentGenerator implements Generator {
|
|
6
6
|
name = 'component'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Generator } from "./index
|
|
2
|
-
import type { GeneratorContext, GeneratorOptions, Template } from "./types
|
|
3
|
-
import { templateEngine } from "./template-engine
|
|
1
|
+
import type { Generator } from "./index"
|
|
2
|
+
import type { GeneratorContext, GeneratorOptions, Template } from "./types"
|
|
3
|
+
import { templateEngine } from "./template-engine"
|
|
4
4
|
|
|
5
5
|
export class ControllerGenerator implements Generator {
|
|
6
6
|
name = 'controller'
|
|
@@ -55,7 +55,7 @@ export class ControllerGenerator implements Generator {
|
|
|
55
55
|
content: `import { Elysia, t } from 'elysia'
|
|
56
56
|
import { {{pascalName}}Service } from '../services/{{kebabName}}.service'
|
|
57
57
|
import { {{pascalName}}Schema, Create{{pascalName}}Schema, Update{{pascalName}}Schema } from '../schemas/{{kebabName}}.schema'
|
|
58
|
-
import { NotFoundError, ValidationError } from '
|
|
58
|
+
import { NotFoundError, ValidationError } from '@/core/utils/errors'
|
|
59
59
|
|
|
60
60
|
export class {{pascalName}}Controller {
|
|
61
61
|
private service: {{pascalName}}Service
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { CliCommand } from "../../plugins/types
|
|
2
|
-
import { ControllerGenerator } from "./controller
|
|
3
|
-
import { RouteGenerator } from "./route
|
|
4
|
-
import { ComponentGenerator } from "./component
|
|
5
|
-
import { ServiceGenerator } from "./service
|
|
6
|
-
import { PluginGenerator } from "./plugin
|
|
7
|
-
import type { GeneratorContext, GeneratorOptions } from "./types
|
|
1
|
+
import type { CliCommand } from "../../plugins/types"
|
|
2
|
+
import { ControllerGenerator } from "./controller"
|
|
3
|
+
import { RouteGenerator } from "./route"
|
|
4
|
+
import { ComponentGenerator } from "./component"
|
|
5
|
+
import { ServiceGenerator } from "./service"
|
|
6
|
+
import { PluginGenerator } from "./plugin"
|
|
7
|
+
import type { GeneratorContext, GeneratorOptions } from "./types"
|
|
8
8
|
|
|
9
9
|
export interface Generator {
|
|
10
10
|
name: string
|
|
@@ -47,7 +47,7 @@ export class GeneratorRegistry {
|
|
|
47
47
|
export const generatorRegistry = new GeneratorRegistry()
|
|
48
48
|
|
|
49
49
|
// Export additional commands
|
|
50
|
-
export { interactiveGenerateCommand } from "./interactive
|
|
50
|
+
export { interactiveGenerateCommand } from "./interactive"
|
|
51
51
|
|
|
52
52
|
// CLI command for code generation
|
|
53
53
|
export const generateCommand: CliCommand = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CliCommand } from "../../plugins/types
|
|
2
|
-
import { generatorRegistry } from "./index
|
|
3
|
-
import type { GeneratorContext, GeneratorOptions } from "./types
|
|
4
|
-
import { promptSystem } from "./prompts
|
|
1
|
+
import type { CliCommand } from "../../plugins/types"
|
|
2
|
+
import { generatorRegistry } from "./index"
|
|
3
|
+
import type { GeneratorContext, GeneratorOptions } from "./types"
|
|
4
|
+
import { promptSystem } from "./prompts"
|
|
5
5
|
|
|
6
6
|
export const interactiveGenerateCommand: CliCommand = {
|
|
7
7
|
name: 'generate:interactive',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Generator } from "./index
|
|
2
|
-
import type { GeneratorContext, GeneratorOptions, Template } from "./types
|
|
3
|
-
import { templateEngine } from "./template-engine
|
|
1
|
+
import type { Generator } from "./index"
|
|
2
|
+
import type { GeneratorContext, GeneratorOptions, Template } from "./types"
|
|
3
|
+
import { templateEngine } from "./template-engine"
|
|
4
4
|
import { join } from "path"
|
|
5
5
|
|
|
6
6
|
export class PluginGenerator implements Generator {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Generator } from "./index
|
|
2
|
-
import type { GeneratorContext, GeneratorOptions, Template } from "./types
|
|
3
|
-
import { templateEngine } from "./template-engine
|
|
1
|
+
import type { Generator } from "./index"
|
|
2
|
+
import type { GeneratorContext, GeneratorOptions, Template } from "./types"
|
|
3
|
+
import { templateEngine } from "./template-engine"
|
|
4
4
|
|
|
5
5
|
export class RouteGenerator implements Generator {
|
|
6
6
|
name = 'route'
|
|
@@ -54,15 +54,23 @@ export class RouteGenerator implements Generator {
|
|
|
54
54
|
path: 'app/server/routes/{{kebabName}}.routes.ts',
|
|
55
55
|
content: `import { Elysia, t } from 'elysia'
|
|
56
56
|
import { {{pascalName}}Controller } from '../controllers/{{kebabName}}.controller'
|
|
57
|
-
import { errorHandler } from '
|
|
58
|
-
import { logger } from '
|
|
57
|
+
import { errorHandler } from '@/core/utils/errors/middleware'
|
|
58
|
+
import { logger } from '@/core/utils/logger'
|
|
59
59
|
|
|
60
60
|
const controller = new {{pascalName}}Controller()
|
|
61
61
|
|
|
62
62
|
export const {{camelName}}Routes = new Elysia({ prefix: '/api/{{kebabName}}s' })
|
|
63
63
|
.use(errorHandler)
|
|
64
64
|
.onBeforeHandle(({ request }) => {
|
|
65
|
-
|
|
65
|
+
const url = (() => {
|
|
66
|
+
try {
|
|
67
|
+
return new URL(request.url)
|
|
68
|
+
} catch {
|
|
69
|
+
const host = request.headers.get('host') || 'localhost'
|
|
70
|
+
return new URL(request.url, \`http://\${host}\`)
|
|
71
|
+
}
|
|
72
|
+
})()
|
|
73
|
+
logger.request(request.method, url.pathname)
|
|
66
74
|
})
|
|
67
75
|
.get('/', async () => {
|
|
68
76
|
return await controller.getAll()
|
|
@@ -300,16 +308,24 @@ export const {{camelName}}Routes = new Elysia({ prefix: '/api/{{kebabName}}s' })
|
|
|
300
308
|
path: 'app/server/routes/auth.routes.ts',
|
|
301
309
|
content: `import { Elysia, t } from 'elysia'
|
|
302
310
|
import { AuthController } from '../controllers/auth.controller'
|
|
303
|
-
import { errorHandler } from '
|
|
311
|
+
import { errorHandler } from '@/core/utils/errors/middleware'
|
|
304
312
|
import { authMiddleware } from '../middleware/auth.middleware'
|
|
305
|
-
import { logger } from '
|
|
313
|
+
import { logger } from '@/core/utils/logger'
|
|
306
314
|
|
|
307
315
|
const controller = new AuthController()
|
|
308
316
|
|
|
309
317
|
export const authRoutes = new Elysia({ prefix: '/api/auth' })
|
|
310
318
|
.use(errorHandler)
|
|
311
319
|
.onBeforeHandle(({ request }) => {
|
|
312
|
-
|
|
320
|
+
const url = (() => {
|
|
321
|
+
try {
|
|
322
|
+
return new URL(request.url)
|
|
323
|
+
} catch {
|
|
324
|
+
const host = request.headers.get('host') || 'localhost'
|
|
325
|
+
return new URL(request.url, \`http://\${host}\`)
|
|
326
|
+
}
|
|
327
|
+
})()
|
|
328
|
+
logger.request(request.method, url.pathname)
|
|
313
329
|
})
|
|
314
330
|
.post('/register', async ({ body }) => {
|
|
315
331
|
return await controller.register({ body })
|
|
@@ -456,8 +472,8 @@ export const authRoutes = new Elysia({ prefix: '/api/auth' })
|
|
|
456
472
|
{
|
|
457
473
|
path: 'app/server/middleware/auth.middleware.ts',
|
|
458
474
|
content: `import { Context } from 'elysia'
|
|
459
|
-
import { UnauthorizedError } from '
|
|
460
|
-
import { logger } from '
|
|
475
|
+
import { UnauthorizedError } from '@/core/utils/errors'
|
|
476
|
+
import { logger } from '@/core/utils/logger'
|
|
461
477
|
|
|
462
478
|
// JWT verification function (implement based on your JWT library)
|
|
463
479
|
async function verifyJWT(token: string): Promise<any> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Generator } from "./index
|
|
2
|
-
import type { GeneratorContext, GeneratorOptions, Template } from "./types
|
|
3
|
-
import { templateEngine } from "./template-engine
|
|
1
|
+
import type { Generator } from "./index"
|
|
2
|
+
import type { GeneratorContext, GeneratorOptions, Template } from "./types"
|
|
3
|
+
import { templateEngine } from "./template-engine"
|
|
4
4
|
|
|
5
5
|
export class ServiceGenerator implements Generator {
|
|
6
6
|
name = 'service'
|
|
@@ -54,8 +54,8 @@ export class ServiceGenerator implements Generator {
|
|
|
54
54
|
path: 'app/server/services/{{kebabName}}.service.ts',
|
|
55
55
|
content: `import { {{pascalName}}, Create{{pascalName}}, Update{{pascalName}} } from '../schemas/{{kebabName}}.schema'
|
|
56
56
|
import { {{pascalName}}Repository } from '../repositories/{{kebabName}}.repository'
|
|
57
|
-
import { ValidationError, NotFoundError } from '
|
|
58
|
-
import { logger } from '
|
|
57
|
+
import { ValidationError, NotFoundError } from '@/core/utils/errors'
|
|
58
|
+
import { logger } from '@/core/utils/logger'
|
|
59
59
|
|
|
60
60
|
export class {{pascalName}}Service {
|
|
61
61
|
private repository: {{pascalName}}Repository
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GeneratorContext, GeneratorOptions, Template, TemplateFile, GeneratedFile, TemplateProcessor } from "./types
|
|
1
|
+
import type { GeneratorContext, GeneratorOptions, Template, TemplateFile, GeneratedFile, TemplateProcessor } from "./types"
|
|
2
2
|
import { join, dirname } from "path"
|
|
3
3
|
import { mkdir, writeFile, readFile, stat } from "fs/promises"
|
|
4
4
|
import { existsSync } from "fs"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FluxStackConfig } from "../../config/schema"
|
|
2
|
-
import type { Logger } from "
|
|
2
|
+
import type { Logger } from "@/core/utils/logger/index"
|
|
3
3
|
import type { PluginUtils } from "../../plugins/types"
|
|
4
4
|
|
|
5
5
|
export interface GeneratorContext {
|