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/config/app.config.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Application Configuration
|
|
3
|
-
*
|
|
3
|
+
* Core application metadata and global settings
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { defineConfig, config } from '@/core/utils/config-schema'
|
|
@@ -8,6 +8,7 @@ import { FLUXSTACK_VERSION } from '@/core/utils/version'
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* App configuration schema
|
|
11
|
+
* Contains only app-level metadata and global feature flags
|
|
11
12
|
*/
|
|
12
13
|
const appConfigSchema = {
|
|
13
14
|
// App basics
|
|
@@ -25,52 +26,9 @@ const appConfigSchema = {
|
|
|
25
26
|
// Environment
|
|
26
27
|
env: config.enum('NODE_ENV', ['development', 'production', 'test'] as const, 'development', true),
|
|
27
28
|
|
|
28
|
-
debug: config.boolean('DEBUG', false),
|
|
29
|
-
|
|
30
|
-
// Server
|
|
31
|
-
port: {
|
|
32
|
-
type: 'number' as const,
|
|
33
|
-
env: 'PORT',
|
|
34
|
-
default: 3000,
|
|
35
|
-
required: true,
|
|
36
|
-
validate: (value: number) => {
|
|
37
|
-
if (value < 1 || value > 65535) {
|
|
38
|
-
return 'Port must be between 1 and 65535'
|
|
39
|
-
}
|
|
40
|
-
return true
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
host: config.string('HOST', 'localhost', true),
|
|
45
|
-
|
|
46
|
-
apiPrefix: {
|
|
47
|
-
type: 'string' as const,
|
|
48
|
-
env: 'API_PREFIX',
|
|
49
|
-
default: '/api',
|
|
50
|
-
validate: (value: string) => value.startsWith('/') || 'API prefix must start with /'
|
|
51
|
-
},
|
|
52
|
-
|
|
53
29
|
// URLs
|
|
54
30
|
url: config.string('APP_URL', undefined, false),
|
|
55
31
|
|
|
56
|
-
// Features
|
|
57
|
-
enableSwagger: config.boolean('ENABLE_SWAGGER', true),
|
|
58
|
-
enableMetrics: config.boolean('ENABLE_METRICS', false),
|
|
59
|
-
enableMonitoring: config.boolean('ENABLE_MONITORING', false),
|
|
60
|
-
|
|
61
|
-
// Client
|
|
62
|
-
clientPort: config.number('VITE_PORT', 5173),
|
|
63
|
-
|
|
64
|
-
// Logging
|
|
65
|
-
logLevel: config.enum('LOG_LEVEL', ['debug', 'info', 'warn', 'error'] as const, 'info'),
|
|
66
|
-
logFormat: config.enum('LOG_FORMAT', ['json', 'pretty'] as const, 'pretty'),
|
|
67
|
-
|
|
68
|
-
// CORS
|
|
69
|
-
corsOrigins: config.array('CORS_ORIGINS', ['*']),
|
|
70
|
-
corsMethods: config.array('CORS_METHODS', ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']),
|
|
71
|
-
corsHeaders: config.array('CORS_HEADERS', ['Content-Type', 'Authorization']),
|
|
72
|
-
corsCredentials: config.boolean('CORS_CREDENTIALS', false),
|
|
73
|
-
|
|
74
32
|
// Security
|
|
75
33
|
trustProxy: config.boolean('TRUST_PROXY', false),
|
|
76
34
|
|
|
@@ -100,15 +58,5 @@ export type AppConfig = typeof appConfig
|
|
|
100
58
|
*/
|
|
101
59
|
export type Environment = typeof appConfig.env
|
|
102
60
|
|
|
103
|
-
/**
|
|
104
|
-
* Type-safe log level type
|
|
105
|
-
*/
|
|
106
|
-
export type LogLevel = typeof appConfig.logLevel
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Type-safe log format type
|
|
110
|
-
*/
|
|
111
|
-
export type LogFormat = typeof appConfig.logFormat
|
|
112
|
-
|
|
113
61
|
// Export default
|
|
114
62
|
export default appConfig
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client & Vite Configuration
|
|
3
|
+
* Declarative client, proxy and Vite dev server configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { defineConfig, defineNestedConfig, config } from '@/core/utils/config-schema'
|
|
7
|
+
import { env, helpers } from '@/core/utils/env'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Vite Dev Server Configuration
|
|
11
|
+
*/
|
|
12
|
+
const viteSchema = {
|
|
13
|
+
port: config.number('VITE_PORT', 5173, true),
|
|
14
|
+
|
|
15
|
+
host: config.string('VITE_HOST', 'localhost'),
|
|
16
|
+
|
|
17
|
+
strictPort: config.boolean('VITE_STRICT_PORT', false),
|
|
18
|
+
|
|
19
|
+
open: config.boolean('VITE_OPEN', false),
|
|
20
|
+
|
|
21
|
+
enableLogging: config.boolean('ENABLE_VITE_PROXY_LOGS', false)
|
|
22
|
+
} as const
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* API Proxy Configuration
|
|
26
|
+
*/
|
|
27
|
+
const proxySchema = {
|
|
28
|
+
target: {
|
|
29
|
+
type: 'string' as const,
|
|
30
|
+
env: 'PROXY_TARGET',
|
|
31
|
+
default: helpers.getServerUrl(),
|
|
32
|
+
required: false,
|
|
33
|
+
validate: (value: string) => {
|
|
34
|
+
if (!value) return true
|
|
35
|
+
try {
|
|
36
|
+
new URL(value)
|
|
37
|
+
return true
|
|
38
|
+
} catch {
|
|
39
|
+
return 'Proxy target must be a valid URL'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
changeOrigin: config.boolean('PROXY_CHANGE_ORIGIN', true),
|
|
45
|
+
|
|
46
|
+
secure: config.boolean('PROXY_SECURE', false),
|
|
47
|
+
|
|
48
|
+
ws: config.boolean('PROXY_WS', true), // WebSocket support
|
|
49
|
+
|
|
50
|
+
rewrite: {
|
|
51
|
+
type: 'object' as const,
|
|
52
|
+
env: 'PROXY_REWRITE',
|
|
53
|
+
default: {},
|
|
54
|
+
required: false
|
|
55
|
+
}
|
|
56
|
+
} as const
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Client Build Configuration
|
|
60
|
+
*/
|
|
61
|
+
const buildSchema = {
|
|
62
|
+
outDir: config.string('CLIENT_OUTDIR', 'dist/client'),
|
|
63
|
+
|
|
64
|
+
sourceMaps: config.boolean('CLIENT_SOURCEMAPS', helpers.isDevelopment()),
|
|
65
|
+
|
|
66
|
+
minify: config.boolean('CLIENT_MINIFY', helpers.isProduction()),
|
|
67
|
+
|
|
68
|
+
target: config.string('CLIENT_TARGET', 'esnext'),
|
|
69
|
+
|
|
70
|
+
assetsDir: config.string('CLIENT_ASSETS_DIR', 'assets'),
|
|
71
|
+
|
|
72
|
+
cssCodeSplit: config.boolean('CLIENT_CSS_CODE_SPLIT', true),
|
|
73
|
+
|
|
74
|
+
chunkSizeWarningLimit: config.number('CLIENT_CHUNK_SIZE_WARNING', 500), // KB
|
|
75
|
+
|
|
76
|
+
emptyOutDir: config.boolean('CLIENT_EMPTY_OUTDIR', true)
|
|
77
|
+
} as const
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Client Configuration (nested)
|
|
81
|
+
*/
|
|
82
|
+
export const clientConfig = defineNestedConfig({
|
|
83
|
+
vite: viteSchema,
|
|
84
|
+
proxy: proxySchema,
|
|
85
|
+
build: buildSchema
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
// Export types
|
|
89
|
+
export type ViteConfig = typeof clientConfig.vite
|
|
90
|
+
export type ProxyConfig = typeof clientConfig.proxy
|
|
91
|
+
export type ClientBuildConfig = typeof clientConfig.build
|
|
92
|
+
export type ClientConfig = typeof clientConfig
|
|
93
|
+
|
|
94
|
+
// Export default
|
|
95
|
+
export default clientConfig
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @deprecated Use the configuration from the root fluxstack.config.ts instead
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { getConfigSync, createLegacyConfig } from '
|
|
8
|
-
import type { FluxStackConfig } from '
|
|
7
|
+
import { getConfigSync, createLegacyConfig } from '@/core/config'
|
|
8
|
+
import type { FluxStackConfig } from '@/core/config'
|
|
9
9
|
|
|
10
10
|
// Load the new configuration
|
|
11
11
|
const newConfig = getConfigSync()
|
package/config/index.ts
CHANGED
|
@@ -5,72 +5,107 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
-
* import { appConfig,
|
|
8
|
+
* import { appConfig, serverConfig, databaseConfig } from '@/config'
|
|
9
9
|
*
|
|
10
10
|
* // All configs are type-safe and validated!
|
|
11
|
-
* console.log(appConfig.name)
|
|
12
|
-
* console.log(
|
|
13
|
-
* console.log(
|
|
11
|
+
* console.log(appConfig.name) // string
|
|
12
|
+
* console.log(serverConfig.server.port) // number
|
|
13
|
+
* console.log(clientConfig.vite.port) // number
|
|
14
14
|
*
|
|
15
15
|
* // Nested configs
|
|
16
|
-
* console.log(servicesConfig.email.host)
|
|
17
|
-
* console.log(
|
|
16
|
+
* console.log(servicesConfig.email.host) // string
|
|
17
|
+
* console.log(monitoringConfig.metrics.enabled) // boolean
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// 📦 CONFIG EXPORTS
|
|
23
|
+
// ============================================================================
|
|
24
|
+
|
|
21
25
|
export { appConfig } from './app.config'
|
|
26
|
+
export { serverConfig } from './server.config'
|
|
27
|
+
export { clientConfig } from './client.config'
|
|
22
28
|
export { databaseConfig } from './database.config'
|
|
23
29
|
export { servicesConfig } from './services.config'
|
|
24
|
-
export { serverConfig } from './server.config'
|
|
25
30
|
export { loggerConfig } from './logger.config'
|
|
26
|
-
export {
|
|
31
|
+
export { pluginsConfig } from './plugins.config'
|
|
32
|
+
export { monitoringConfig } from './monitoring.config'
|
|
27
33
|
export { appRuntimeConfig } from './runtime.config'
|
|
28
34
|
export { systemConfig, systemRuntimeInfo } from './system.config'
|
|
29
35
|
|
|
30
36
|
// Plugin configs (re-exported for convenience)
|
|
31
37
|
export { cryptoAuthConfig } from '../plugins/crypto-auth/config'
|
|
32
38
|
|
|
33
|
-
//
|
|
34
|
-
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// 📝 TYPE EXPORTS
|
|
41
|
+
// ============================================================================
|
|
42
|
+
|
|
43
|
+
// Core types
|
|
44
|
+
export type { AppConfig, Environment } from './app.config'
|
|
45
|
+
export type {
|
|
46
|
+
ServerConfig,
|
|
47
|
+
CorsConfig,
|
|
48
|
+
ServerFullConfig
|
|
49
|
+
} from './server.config'
|
|
50
|
+
export type {
|
|
51
|
+
ClientConfig,
|
|
52
|
+
ViteConfig,
|
|
53
|
+
ProxyConfig,
|
|
54
|
+
ClientBuildConfig
|
|
55
|
+
} from './client.config'
|
|
35
56
|
export type { DatabaseConfig } from './database.config'
|
|
36
|
-
export type { ServerConfig } from './server.config'
|
|
37
|
-
export type { LoggerConfig } from './logger.config'
|
|
38
|
-
export type { BuildConfig } from './build.config'
|
|
39
|
-
export type { SystemConfig, SystemRuntimeInfo } from './system.config'
|
|
40
57
|
export type {
|
|
41
58
|
EmailConfig,
|
|
42
59
|
JWTConfig,
|
|
43
60
|
StorageConfig,
|
|
44
61
|
RedisConfig
|
|
45
62
|
} from './services.config'
|
|
63
|
+
export type { LoggerConfig } from './logger.config'
|
|
64
|
+
export type { PluginsConfig } from './plugins.config'
|
|
65
|
+
export type {
|
|
66
|
+
MonitoringConfig,
|
|
67
|
+
MetricsConfig,
|
|
68
|
+
ProfilingConfig,
|
|
69
|
+
MonitoringFullConfig
|
|
70
|
+
} from './monitoring.config'
|
|
71
|
+
export type { SystemConfig, SystemRuntimeInfo } from './system.config'
|
|
46
72
|
|
|
47
73
|
// Plugin types
|
|
48
74
|
export type { CryptoAuthConfig } from '../plugins/crypto-auth/config'
|
|
49
75
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// 🎯 UNIFIED CONFIG OBJECT
|
|
78
|
+
// ============================================================================
|
|
79
|
+
|
|
53
80
|
import { appConfig } from './app.config'
|
|
81
|
+
import { serverConfig } from './server.config'
|
|
82
|
+
import { clientConfig } from './client.config'
|
|
54
83
|
import { databaseConfig } from './database.config'
|
|
55
84
|
import { servicesConfig } from './services.config'
|
|
56
|
-
import { serverConfig } from './server.config'
|
|
57
85
|
import { loggerConfig } from './logger.config'
|
|
58
|
-
import {
|
|
86
|
+
import { pluginsConfig } from './plugins.config'
|
|
87
|
+
import { monitoringConfig } from './monitoring.config'
|
|
59
88
|
import { appRuntimeConfig } from './runtime.config'
|
|
60
89
|
import { systemConfig, systemRuntimeInfo } from './system.config'
|
|
61
90
|
import { cryptoAuthConfig } from '../plugins/crypto-auth/config'
|
|
62
91
|
|
|
92
|
+
/**
|
|
93
|
+
* All configs in one object
|
|
94
|
+
* Use this when you need access to multiple configs at once
|
|
95
|
+
*/
|
|
63
96
|
export const config = {
|
|
64
97
|
app: appConfig,
|
|
98
|
+
server: serverConfig,
|
|
99
|
+
client: clientConfig,
|
|
65
100
|
database: databaseConfig,
|
|
66
101
|
services: servicesConfig,
|
|
67
|
-
server: serverConfig,
|
|
68
102
|
logger: loggerConfig,
|
|
69
|
-
|
|
103
|
+
plugins: pluginsConfig,
|
|
104
|
+
monitoring: monitoringConfig,
|
|
70
105
|
runtime: appRuntimeConfig,
|
|
71
106
|
system: systemConfig,
|
|
72
107
|
systemRuntime: systemRuntimeInfo,
|
|
73
108
|
cryptoAuth: cryptoAuthConfig
|
|
74
|
-
}
|
|
109
|
+
} as const
|
|
75
110
|
|
|
76
111
|
export default config
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monitoring Configuration
|
|
3
|
+
* Declarative monitoring, metrics and profiling configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { defineConfig, defineNestedConfig, config } from '@/core/utils/config-schema'
|
|
7
|
+
import { helpers } from '@/core/utils/env'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Metrics Configuration Schema
|
|
11
|
+
*/
|
|
12
|
+
const metricsSchema = {
|
|
13
|
+
enabled: config.boolean('ENABLE_METRICS', false),
|
|
14
|
+
|
|
15
|
+
collectInterval: {
|
|
16
|
+
type: 'number' as const,
|
|
17
|
+
env: 'METRICS_INTERVAL',
|
|
18
|
+
default: 5000,
|
|
19
|
+
validate: (value: number) => {
|
|
20
|
+
if (value < 1000) {
|
|
21
|
+
return 'Metrics interval must be at least 1000ms'
|
|
22
|
+
}
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
httpMetrics: config.boolean('HTTP_METRICS', true),
|
|
28
|
+
|
|
29
|
+
systemMetrics: config.boolean('SYSTEM_METRICS', true),
|
|
30
|
+
|
|
31
|
+
customMetrics: config.boolean('CUSTOM_METRICS', false),
|
|
32
|
+
|
|
33
|
+
// Metric exporters
|
|
34
|
+
exportToConsole: config.boolean('METRICS_EXPORT_CONSOLE', helpers.isDevelopment()),
|
|
35
|
+
|
|
36
|
+
exportToFile: config.boolean('METRICS_EXPORT_FILE', false),
|
|
37
|
+
|
|
38
|
+
exportToHttp: config.boolean('METRICS_EXPORT_HTTP', false),
|
|
39
|
+
|
|
40
|
+
exportHttpUrl: config.string('METRICS_EXPORT_URL'),
|
|
41
|
+
|
|
42
|
+
// Metric storage
|
|
43
|
+
retentionPeriod: config.number('METRICS_RETENTION_PERIOD', 3600000), // 1 hour in ms
|
|
44
|
+
|
|
45
|
+
maxDataPoints: config.number('METRICS_MAX_DATA_POINTS', 1000)
|
|
46
|
+
} as const
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Profiling Configuration Schema
|
|
50
|
+
*/
|
|
51
|
+
const profilingSchema = {
|
|
52
|
+
enabled: config.boolean('PROFILING_ENABLED', false),
|
|
53
|
+
|
|
54
|
+
sampleRate: {
|
|
55
|
+
type: 'number' as const,
|
|
56
|
+
env: 'PROFILING_SAMPLE_RATE',
|
|
57
|
+
default: helpers.isProduction() ? 0.01 : 0.1,
|
|
58
|
+
validate: (value: number) => {
|
|
59
|
+
if (value < 0 || value > 1) {
|
|
60
|
+
return 'Sample rate must be between 0 and 1'
|
|
61
|
+
}
|
|
62
|
+
return true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
memoryProfiling: config.boolean('MEMORY_PROFILING', false),
|
|
67
|
+
|
|
68
|
+
cpuProfiling: config.boolean('CPU_PROFILING', false),
|
|
69
|
+
|
|
70
|
+
heapSnapshot: config.boolean('HEAP_SNAPSHOT', false),
|
|
71
|
+
|
|
72
|
+
// Profiling output
|
|
73
|
+
outputDir: config.string('PROFILING_OUTPUT_DIR', 'profiling'),
|
|
74
|
+
|
|
75
|
+
maxProfiles: config.number('PROFILING_MAX_PROFILES', 10)
|
|
76
|
+
} as const
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Monitoring Configuration Schema
|
|
80
|
+
*/
|
|
81
|
+
const monitoringSchema = {
|
|
82
|
+
enabled: config.boolean('ENABLE_MONITORING', false),
|
|
83
|
+
|
|
84
|
+
// Exporters
|
|
85
|
+
exporters: config.array('MONITORING_EXPORTERS', []),
|
|
86
|
+
|
|
87
|
+
// Health checks
|
|
88
|
+
enableHealthChecks: config.boolean('ENABLE_HEALTH_CHECKS', true),
|
|
89
|
+
|
|
90
|
+
healthCheckInterval: config.number('HEALTH_CHECK_INTERVAL', 30000), // 30s
|
|
91
|
+
|
|
92
|
+
// Alerting
|
|
93
|
+
enableAlerts: config.boolean('ENABLE_ALERTS', false),
|
|
94
|
+
|
|
95
|
+
alertWebhook: config.string('ALERT_WEBHOOK')
|
|
96
|
+
} as const
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Export monitoring config (nested)
|
|
100
|
+
*/
|
|
101
|
+
export const monitoringConfig = defineNestedConfig({
|
|
102
|
+
monitoring: monitoringSchema,
|
|
103
|
+
metrics: metricsSchema,
|
|
104
|
+
profiling: profilingSchema
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
// Export types
|
|
108
|
+
export type MonitoringConfig = typeof monitoringConfig.monitoring
|
|
109
|
+
export type MetricsConfig = typeof monitoringConfig.metrics
|
|
110
|
+
export type ProfilingConfig = typeof monitoringConfig.profiling
|
|
111
|
+
export type MonitoringFullConfig = typeof monitoringConfig
|
|
112
|
+
|
|
113
|
+
// Export default
|
|
114
|
+
export default monitoringConfig
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugins Configuration
|
|
3
|
+
* Declarative plugin management configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { defineConfig, config } from '@/core/utils/config-schema'
|
|
7
|
+
import { env } from '@/core/utils/env'
|
|
8
|
+
import { FLUXSTACK_VERSION } from '@/core/utils/version'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Plugins configuration schema
|
|
12
|
+
*/
|
|
13
|
+
const pluginsConfigSchema = {
|
|
14
|
+
// Plugin management
|
|
15
|
+
enabled: config.array(
|
|
16
|
+
'FLUXSTACK_PLUGINS_ENABLED',
|
|
17
|
+
['logger', 'swagger', 'vite', 'cors', 'static-files', 'crypto-auth']
|
|
18
|
+
),
|
|
19
|
+
|
|
20
|
+
disabled: config.array('FLUXSTACK_PLUGINS_DISABLED', []),
|
|
21
|
+
|
|
22
|
+
// Auto-discovery
|
|
23
|
+
autoDiscover: config.boolean('PLUGINS_AUTO_DISCOVER', true),
|
|
24
|
+
|
|
25
|
+
pluginsDir: config.string('PLUGINS_DIR', 'plugins'),
|
|
26
|
+
|
|
27
|
+
// Plugin-specific configurations
|
|
28
|
+
// Logger plugin (handled by logger.config.ts)
|
|
29
|
+
loggerEnabled: config.boolean('LOGGER_PLUGIN_ENABLED', true),
|
|
30
|
+
|
|
31
|
+
// Swagger plugin
|
|
32
|
+
swaggerEnabled: config.boolean('SWAGGER_ENABLED', true),
|
|
33
|
+
swaggerTitle: config.string('SWAGGER_TITLE', 'FluxStack API'),
|
|
34
|
+
swaggerVersion: config.string('SWAGGER_VERSION', FLUXSTACK_VERSION),
|
|
35
|
+
swaggerDescription: config.string(
|
|
36
|
+
'SWAGGER_DESCRIPTION',
|
|
37
|
+
'API documentation for FluxStack application'
|
|
38
|
+
),
|
|
39
|
+
swaggerPath: config.string('SWAGGER_PATH', '/swagger'),
|
|
40
|
+
|
|
41
|
+
// Swagger advanced options
|
|
42
|
+
swaggerExcludePaths: config.array('SWAGGER_EXCLUDE_PATHS', []),
|
|
43
|
+
|
|
44
|
+
// Swagger servers (comma-separated list of URLs)
|
|
45
|
+
// Format: "url1|description1,url2|description2"
|
|
46
|
+
// Example: "https://api.prod.com|Production,https://api.staging.com|Staging"
|
|
47
|
+
swaggerServers: config.string('SWAGGER_SERVERS', ''),
|
|
48
|
+
|
|
49
|
+
// Swagger UI options
|
|
50
|
+
swaggerPersistAuthorization: config.boolean('SWAGGER_PERSIST_AUTH', true),
|
|
51
|
+
swaggerDisplayRequestDuration: config.boolean('SWAGGER_DISPLAY_DURATION', true),
|
|
52
|
+
swaggerEnableFilter: config.boolean('SWAGGER_ENABLE_FILTER', true),
|
|
53
|
+
swaggerShowExtensions: config.boolean('SWAGGER_SHOW_EXTENSIONS', true),
|
|
54
|
+
swaggerTryItOutEnabled: config.boolean('SWAGGER_TRY_IT_OUT', true),
|
|
55
|
+
|
|
56
|
+
// Swagger authentication (Basic Auth)
|
|
57
|
+
swaggerAuthEnabled: config.boolean('SWAGGER_AUTH_ENABLED', false),
|
|
58
|
+
swaggerAuthUsername: config.string('SWAGGER_AUTH_USERNAME', 'admin'),
|
|
59
|
+
swaggerAuthPassword: config.string('SWAGGER_AUTH_PASSWORD', ''),
|
|
60
|
+
|
|
61
|
+
// Static files plugin
|
|
62
|
+
staticFilesEnabled: config.boolean('STATIC_FILES_ENABLED', true),
|
|
63
|
+
staticPublicDir: config.string('STATIC_PUBLIC_DIR', 'public'),
|
|
64
|
+
staticUploadsDir: config.string('STATIC_UPLOADS_DIR', 'uploads'),
|
|
65
|
+
staticCacheMaxAge: config.number('STATIC_CACHE_MAX_AGE', 31536000), // 1 year
|
|
66
|
+
staticEnableUploads: config.boolean('STATIC_ENABLE_UPLOADS', true),
|
|
67
|
+
staticEnablePublic: config.boolean('STATIC_ENABLE_PUBLIC', true),
|
|
68
|
+
|
|
69
|
+
// CORS plugin (configuration via server.config.ts)
|
|
70
|
+
// Vite plugin
|
|
71
|
+
viteEnabled: config.boolean('VITE_PLUGIN_ENABLED', true)
|
|
72
|
+
} as const
|
|
73
|
+
|
|
74
|
+
export const pluginsConfig = defineConfig(pluginsConfigSchema)
|
|
75
|
+
|
|
76
|
+
// Export type
|
|
77
|
+
export type PluginsConfig = typeof pluginsConfig
|
|
78
|
+
|
|
79
|
+
// Export default
|
|
80
|
+
export default pluginsConfig
|
package/config/runtime.config.ts
CHANGED
|
@@ -16,19 +16,6 @@ export const appRuntimeConfig = defineReactiveConfig({
|
|
|
16
16
|
enableMonitoring: config.boolean('ENABLE_MONITORING', false),
|
|
17
17
|
enableDebugMode: config.boolean('DEBUG', false),
|
|
18
18
|
|
|
19
|
-
// Logging level can be changed in runtime
|
|
20
|
-
logLevel: config.enum(
|
|
21
|
-
'LOG_LEVEL',
|
|
22
|
-
['debug', 'info', 'warn', 'error'] as const,
|
|
23
|
-
'info'
|
|
24
|
-
),
|
|
25
|
-
|
|
26
|
-
logFormat: config.enum(
|
|
27
|
-
'LOG_FORMAT',
|
|
28
|
-
['json', 'pretty'] as const,
|
|
29
|
-
'pretty'
|
|
30
|
-
),
|
|
31
|
-
|
|
32
19
|
// Rate limiting
|
|
33
20
|
rateLimitEnabled: config.boolean('RATE_LIMIT_ENABLED', true),
|
|
34
21
|
|
|
@@ -62,9 +49,6 @@ export const appRuntimeConfig = defineReactiveConfig({
|
|
|
62
49
|
validate: (value: number) => value > 0 || 'Max upload size must be positive'
|
|
63
50
|
},
|
|
64
51
|
|
|
65
|
-
// Allowed origins (can be updated in runtime)
|
|
66
|
-
corsOrigins: config.array('CORS_ORIGINS', ['*']),
|
|
67
|
-
|
|
68
52
|
// Maintenance mode
|
|
69
53
|
maintenanceMode: config.boolean('MAINTENANCE_MODE', false),
|
|
70
54
|
|
|
@@ -80,7 +64,6 @@ export const appRuntimeConfig = defineReactiveConfig({
|
|
|
80
64
|
appRuntimeConfig.watch((newConfig) => {
|
|
81
65
|
console.log('🔄 Runtime config reloaded:')
|
|
82
66
|
console.log(' Debug:', newConfig.enableDebugMode)
|
|
83
|
-
console.log(' Log Level:', newConfig.logLevel)
|
|
84
67
|
console.log(' Maintenance:', newConfig.maintenanceMode)
|
|
85
68
|
})
|
|
86
69
|
|
package/config/server.config.ts
CHANGED
|
@@ -1,48 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server Configuration
|
|
3
|
-
*
|
|
3
|
+
* Server-specific settings (port, host, CORS, middleware)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { defineConfig, config } from '@/core/utils/config-schema'
|
|
7
|
-
import { FLUXSTACK_VERSION } from '@/core/utils/version'
|
|
6
|
+
import { defineConfig, defineNestedConfig, config } from '@/core/utils/config-schema'
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* CORS configuration schema
|
|
10
|
+
*/
|
|
11
|
+
const corsSchema = {
|
|
12
|
+
origins: config.array('CORS_ORIGINS', ['http://localhost:3000', 'http://localhost:5173']),
|
|
13
|
+
methods: config.array('CORS_METHODS', ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']),
|
|
14
|
+
headers: config.array('CORS_HEADERS', ['Content-Type', 'Authorization']),
|
|
15
|
+
credentials: config.boolean('CORS_CREDENTIALS', false),
|
|
16
|
+
maxAge: config.number('CORS_MAX_AGE', 86400)
|
|
17
|
+
} as const
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Server configuration schema
|
|
21
|
+
*/
|
|
22
|
+
const serverSchema = {
|
|
10
23
|
// Server basics
|
|
11
|
-
port:
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
port: {
|
|
25
|
+
type: 'number' as const,
|
|
26
|
+
env: 'PORT',
|
|
27
|
+
default: 3000,
|
|
28
|
+
required: true,
|
|
29
|
+
validate: (value: number) => {
|
|
30
|
+
if (value < 1 || value > 65535) {
|
|
31
|
+
return 'Port must be between 1 and 65535'
|
|
32
|
+
}
|
|
33
|
+
return true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
14
36
|
|
|
15
|
-
|
|
16
|
-
corsOrigins: config.array('CORS_ORIGINS', ['http://localhost:3000', 'http://localhost:5173']),
|
|
17
|
-
corsMethods: config.array('CORS_METHODS', ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']),
|
|
18
|
-
corsHeaders: config.array('CORS_HEADERS', ['Content-Type', 'Authorization']),
|
|
19
|
-
corsCredentials: config.boolean('CORS_CREDENTIALS', false),
|
|
20
|
-
corsMaxAge: config.number('CORS_MAX_AGE', 86400),
|
|
37
|
+
host: config.string('HOST', 'localhost', true),
|
|
21
38
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
apiPrefix: {
|
|
40
|
+
type: 'string' as const,
|
|
41
|
+
env: 'API_PREFIX',
|
|
42
|
+
default: '/api',
|
|
43
|
+
validate: (value: string) => value.startsWith('/') || 'API prefix must start with /'
|
|
44
|
+
},
|
|
27
45
|
|
|
28
46
|
// Backend-only mode
|
|
29
47
|
backendPort: config.number('BACKEND_PORT', 3001),
|
|
30
48
|
|
|
31
|
-
// App info
|
|
32
|
-
appName: config.string('FLUXSTACK_APP_NAME', 'FluxStack'),
|
|
33
|
-
appVersion: config.string('FLUXSTACK_APP_VERSION', FLUXSTACK_VERSION),
|
|
34
|
-
|
|
35
49
|
// Features
|
|
36
|
-
enableSwagger: config.boolean('ENABLE_SWAGGER', true),
|
|
37
|
-
enableMetrics: config.boolean('ENABLE_METRICS', false),
|
|
38
|
-
enableMonitoring: config.boolean('ENABLE_MONITORING', false),
|
|
39
50
|
enableRequestLogging: config.boolean('ENABLE_REQUEST_LOGGING', true),
|
|
40
|
-
|
|
41
|
-
// Vite/Development
|
|
42
|
-
enableViteProxyLogs: config.boolean('ENABLE_VITE_PROXY_LOGS', false)
|
|
51
|
+
showBanner: config.boolean('SHOW_SERVER_BANNER', true)
|
|
43
52
|
} as const
|
|
44
53
|
|
|
45
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Export server config (nested with CORS)
|
|
56
|
+
*/
|
|
57
|
+
export const serverConfig = defineNestedConfig({
|
|
58
|
+
server: serverSchema,
|
|
59
|
+
cors: corsSchema
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
// Export types
|
|
63
|
+
export type ServerConfig = typeof serverConfig.server
|
|
64
|
+
export type CorsConfig = typeof serverConfig.cors
|
|
65
|
+
export type ServerFullConfig = typeof serverConfig
|
|
46
66
|
|
|
47
|
-
|
|
67
|
+
// Export default
|
|
48
68
|
export default serverConfig
|