create-fluxstack 1.1.0 → 1.4.0
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/app/server/backend-only.ts +5 -5
- package/app/server/index.ts +63 -54
- package/app/server/live/FluxStackConfig.ts +43 -39
- package/app/server/live/SystemMonitorIntegration.ts +2 -2
- package/app/server/live/register-components.ts +1 -1
- package/app/server/middleware/errorHandling.ts +6 -4
- package/app/server/routes/config.ts +145 -0
- package/app/server/routes/index.ts +5 -3
- package/config/app.config.ts +113 -0
- package/config/build.config.ts +24 -0
- package/config/database.config.ts +99 -0
- package/config/index.ts +68 -0
- package/config/logger.config.ts +27 -0
- package/config/runtime.config.ts +92 -0
- package/config/server.config.ts +46 -0
- package/config/services.config.ts +130 -0
- package/config/system.config.ts +105 -0
- package/core/build/index.ts +10 -4
- package/core/cli/index.ts +29 -12
- package/core/config/env.ts +37 -95
- package/core/config/runtime-config.ts +61 -58
- package/core/config/schema.ts +4 -0
- package/core/framework/server.ts +22 -10
- package/core/plugins/built-in/index.ts +7 -17
- package/core/plugins/built-in/swagger/index.ts +228 -228
- package/core/plugins/built-in/vite/index.ts +374 -358
- package/core/plugins/dependency-manager.ts +5 -5
- package/core/plugins/manager.ts +12 -12
- package/core/plugins/registry.ts +3 -3
- package/core/server/index.ts +0 -1
- package/core/server/live/ComponentRegistry.ts +34 -8
- package/core/server/live/LiveComponentPerformanceMonitor.ts +1 -1
- package/core/server/live/websocket-plugin.ts +434 -434
- package/core/server/middleware/README.md +488 -0
- package/core/server/middleware/elysia-helpers.ts +227 -0
- package/core/server/middleware/index.ts +25 -9
- package/core/server/plugins/static-files-plugin.ts +231 -231
- package/core/utils/config-schema.ts +484 -0
- package/core/utils/env.ts +306 -0
- package/core/utils/helpers.ts +4 -4
- package/core/utils/logger/colors.ts +114 -0
- package/core/utils/logger/config.ts +35 -0
- package/core/utils/logger/formatter.ts +82 -0
- package/core/utils/logger/group-logger.ts +101 -0
- package/core/utils/logger/index.ts +199 -250
- package/core/utils/logger/stack-trace.ts +92 -0
- package/core/utils/logger/startup-banner.ts +92 -0
- package/core/utils/logger/winston-logger.ts +152 -0
- package/core/utils/version.ts +5 -0
- package/create-fluxstack.ts +1 -0
- package/fluxstack.config.ts +2 -2
- package/package.json +117 -115
- package/core/config/env-dynamic.ts +0 -326
- package/core/plugins/built-in/logger/index.ts +0 -180
- package/core/server/plugins/logger.ts +0 -47
- package/core/utils/env-runtime-v2.ts +0 -232
- package/core/utils/env-runtime.ts +0 -259
- package/core/utils/logger/formatters.ts +0 -222
- package/core/utils/logger/middleware.ts +0 -253
- package/core/utils/logger/performance.ts +0 -384
- package/core/utils/logger/transports.ts +0 -365
- package/core/utils/logger.ts +0 -106
|
@@ -1,229 +1,229 @@
|
|
|
1
|
-
import { swagger } from '@elysiajs/swagger'
|
|
2
|
-
import type { Plugin, PluginContext } from '../../types'
|
|
3
|
-
|
|
4
|
-
export const swaggerPlugin: Plugin = {
|
|
5
|
-
name: 'swagger',
|
|
6
|
-
version: '1.0.0',
|
|
7
|
-
description: 'Enhanced Swagger documentation plugin for FluxStack with customizable options',
|
|
8
|
-
author: 'FluxStack Team',
|
|
9
|
-
priority: 500,
|
|
10
|
-
category: 'documentation',
|
|
11
|
-
tags: ['swagger', 'documentation', 'api'],
|
|
12
|
-
dependencies: [], // No dependencies
|
|
13
|
-
|
|
14
|
-
configSchema: {
|
|
15
|
-
type: 'object',
|
|
16
|
-
properties: {
|
|
17
|
-
enabled: {
|
|
18
|
-
type: 'boolean',
|
|
19
|
-
description: 'Enable Swagger documentation'
|
|
20
|
-
},
|
|
21
|
-
path: {
|
|
22
|
-
type: 'string',
|
|
23
|
-
description: 'Swagger UI path'
|
|
24
|
-
},
|
|
25
|
-
title: {
|
|
26
|
-
type: 'string',
|
|
27
|
-
description: 'API documentation title'
|
|
28
|
-
},
|
|
29
|
-
description: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
description: 'API documentation description'
|
|
32
|
-
},
|
|
33
|
-
version: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
description: 'API version'
|
|
36
|
-
},
|
|
37
|
-
tags: {
|
|
38
|
-
type: 'array',
|
|
39
|
-
items: {
|
|
40
|
-
type: 'object',
|
|
41
|
-
properties: {
|
|
42
|
-
name: { type: 'string' },
|
|
43
|
-
description: { type: 'string' }
|
|
44
|
-
},
|
|
45
|
-
required: ['name']
|
|
46
|
-
},
|
|
47
|
-
description: 'API tags for grouping endpoints'
|
|
48
|
-
},
|
|
49
|
-
servers: {
|
|
50
|
-
type: 'array',
|
|
51
|
-
items: {
|
|
52
|
-
type: 'object',
|
|
53
|
-
properties: {
|
|
54
|
-
url: { type: 'string' },
|
|
55
|
-
description: { type: 'string' }
|
|
56
|
-
},
|
|
57
|
-
required: ['url']
|
|
58
|
-
},
|
|
59
|
-
description: 'API servers'
|
|
60
|
-
},
|
|
61
|
-
excludePaths: {
|
|
62
|
-
type: 'array',
|
|
63
|
-
items: { type: 'string' },
|
|
64
|
-
description: 'Paths to exclude from documentation'
|
|
65
|
-
},
|
|
66
|
-
securitySchemes: {
|
|
67
|
-
type: 'object',
|
|
68
|
-
description: 'Security schemes definition'
|
|
69
|
-
},
|
|
70
|
-
globalSecurity: {
|
|
71
|
-
type: 'array',
|
|
72
|
-
items: {
|
|
73
|
-
type: 'object'
|
|
74
|
-
},
|
|
75
|
-
description: 'Global security requirements'
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
additionalProperties: false
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
defaultConfig: {
|
|
82
|
-
enabled: true,
|
|
83
|
-
path: '/swagger',
|
|
84
|
-
title: 'FluxStack API',
|
|
85
|
-
description: 'Modern full-stack TypeScript framework with type-safe API endpoints',
|
|
86
|
-
version: '1.0.0',
|
|
87
|
-
tags: [
|
|
88
|
-
{
|
|
89
|
-
name: 'Health',
|
|
90
|
-
description: 'Health check endpoints'
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: 'API',
|
|
94
|
-
description: 'API endpoints'
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
servers: [],
|
|
98
|
-
excludePaths: [],
|
|
99
|
-
securitySchemes: {},
|
|
100
|
-
globalSecurity: []
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
setup: async (context: PluginContext) => {
|
|
104
|
-
const config = getPluginConfig(context)
|
|
105
|
-
|
|
106
|
-
if (!config.enabled) {
|
|
107
|
-
context.logger.
|
|
108
|
-
return
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
// Build servers list
|
|
113
|
-
const servers = config.servers.length > 0 ? config.servers : [
|
|
114
|
-
{
|
|
115
|
-
url: `http://${context.config.server.host}:${context.config.server.port}`,
|
|
116
|
-
description: 'Development server'
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
|
|
120
|
-
// Add production server if in production
|
|
121
|
-
if (context.utils.isProduction()) {
|
|
122
|
-
servers.push({
|
|
123
|
-
url: 'https://api.example.com', // This would be configured
|
|
124
|
-
description: 'Production server'
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const swaggerConfig = {
|
|
129
|
-
path: config.path,
|
|
130
|
-
documentation: {
|
|
131
|
-
info: {
|
|
132
|
-
title: config.title || context.config.app?.name || 'FluxStack API',
|
|
133
|
-
version: config.version || context.config.app?.version || '1.0.0',
|
|
134
|
-
description: config.description || context.config.app?.description || 'Modern full-stack TypeScript framework with type-safe API endpoints'
|
|
135
|
-
},
|
|
136
|
-
tags: config.tags,
|
|
137
|
-
servers,
|
|
138
|
-
|
|
139
|
-
// Add security schemes if defined
|
|
140
|
-
...(Object.keys(config.securitySchemes).length > 0 && {
|
|
141
|
-
components: {
|
|
142
|
-
securitySchemes: config.securitySchemes
|
|
143
|
-
}
|
|
144
|
-
}),
|
|
145
|
-
|
|
146
|
-
// Add global security if defined
|
|
147
|
-
...(config.globalSecurity.length > 0 && {
|
|
148
|
-
security: config.globalSecurity
|
|
149
|
-
})
|
|
150
|
-
},
|
|
151
|
-
exclude: config.excludePaths,
|
|
152
|
-
swaggerOptions: {
|
|
153
|
-
persistAuthorization: true,
|
|
154
|
-
displayRequestDuration: true,
|
|
155
|
-
filter: true,
|
|
156
|
-
showExtensions: true,
|
|
157
|
-
tryItOutEnabled: true
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
context.app.use(swagger(swaggerConfig))
|
|
162
|
-
|
|
163
|
-
context.logger.
|
|
164
|
-
title: swaggerConfig.documentation.info.title,
|
|
165
|
-
version: swaggerConfig.documentation.info.version,
|
|
166
|
-
servers: servers.length
|
|
167
|
-
})
|
|
168
|
-
} catch (error) {
|
|
169
|
-
context.logger.error('Failed to setup Swagger plugin', { error })
|
|
170
|
-
throw error
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
onServerStart: async (context: PluginContext) => {
|
|
175
|
-
const config = getPluginConfig(context)
|
|
176
|
-
|
|
177
|
-
if (config.enabled) {
|
|
178
|
-
const swaggerUrl = `http://${context.config.server.host}:${context.config.server.port}${config.path}`
|
|
179
|
-
context.logger.
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Helper function to get plugin config from context
|
|
185
|
-
function getPluginConfig(context: PluginContext) {
|
|
186
|
-
// In a real implementation, this would get the config from the plugin context
|
|
187
|
-
// For now, merge default config with any provided config
|
|
188
|
-
const pluginConfig = context.config.plugins.config?.swagger || {}
|
|
189
|
-
return { ...swaggerPlugin.defaultConfig, ...pluginConfig }
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Example usage for security configuration:
|
|
193
|
-
//
|
|
194
|
-
// To enable security in your FluxStack app, configure like this:
|
|
195
|
-
//
|
|
196
|
-
// plugins: {
|
|
197
|
-
// config: {
|
|
198
|
-
// swagger: {
|
|
199
|
-
// securitySchemes: {
|
|
200
|
-
// bearerAuth: {
|
|
201
|
-
// type: 'http',
|
|
202
|
-
// scheme: 'bearer',
|
|
203
|
-
// bearerFormat: 'JWT'
|
|
204
|
-
// },
|
|
205
|
-
// apiKeyAuth: {
|
|
206
|
-
// type: 'apiKey',
|
|
207
|
-
// in: 'header',
|
|
208
|
-
// name: 'X-API-Key'
|
|
209
|
-
// }
|
|
210
|
-
// },
|
|
211
|
-
// globalSecurity: [
|
|
212
|
-
// { bearerAuth: [] } // Apply JWT auth globally
|
|
213
|
-
// ]
|
|
214
|
-
// }
|
|
215
|
-
// }
|
|
216
|
-
// }
|
|
217
|
-
//
|
|
218
|
-
// Then in your routes, you can override per endpoint:
|
|
219
|
-
// app.get('/public', handler, {
|
|
220
|
-
// detail: { security: [] } // No auth required
|
|
221
|
-
// })
|
|
222
|
-
//
|
|
223
|
-
// app.get('/private', handler, {
|
|
224
|
-
// detail: {
|
|
225
|
-
// security: [{ apiKeyAuth: [] }] // API key required
|
|
226
|
-
// }
|
|
227
|
-
// })
|
|
228
|
-
|
|
1
|
+
import { swagger } from '@elysiajs/swagger'
|
|
2
|
+
import type { Plugin, PluginContext } from '../../types'
|
|
3
|
+
|
|
4
|
+
export const swaggerPlugin: Plugin = {
|
|
5
|
+
name: 'swagger',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
description: 'Enhanced Swagger documentation plugin for FluxStack with customizable options',
|
|
8
|
+
author: 'FluxStack Team',
|
|
9
|
+
priority: 500,
|
|
10
|
+
category: 'documentation',
|
|
11
|
+
tags: ['swagger', 'documentation', 'api'],
|
|
12
|
+
dependencies: [], // No dependencies
|
|
13
|
+
|
|
14
|
+
configSchema: {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
enabled: {
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
description: 'Enable Swagger documentation'
|
|
20
|
+
},
|
|
21
|
+
path: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'Swagger UI path'
|
|
24
|
+
},
|
|
25
|
+
title: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'API documentation title'
|
|
28
|
+
},
|
|
29
|
+
description: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'API documentation description'
|
|
32
|
+
},
|
|
33
|
+
version: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'API version'
|
|
36
|
+
},
|
|
37
|
+
tags: {
|
|
38
|
+
type: 'array',
|
|
39
|
+
items: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
name: { type: 'string' },
|
|
43
|
+
description: { type: 'string' }
|
|
44
|
+
},
|
|
45
|
+
required: ['name']
|
|
46
|
+
},
|
|
47
|
+
description: 'API tags for grouping endpoints'
|
|
48
|
+
},
|
|
49
|
+
servers: {
|
|
50
|
+
type: 'array',
|
|
51
|
+
items: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
url: { type: 'string' },
|
|
55
|
+
description: { type: 'string' }
|
|
56
|
+
},
|
|
57
|
+
required: ['url']
|
|
58
|
+
},
|
|
59
|
+
description: 'API servers'
|
|
60
|
+
},
|
|
61
|
+
excludePaths: {
|
|
62
|
+
type: 'array',
|
|
63
|
+
items: { type: 'string' },
|
|
64
|
+
description: 'Paths to exclude from documentation'
|
|
65
|
+
},
|
|
66
|
+
securitySchemes: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
description: 'Security schemes definition'
|
|
69
|
+
},
|
|
70
|
+
globalSecurity: {
|
|
71
|
+
type: 'array',
|
|
72
|
+
items: {
|
|
73
|
+
type: 'object'
|
|
74
|
+
},
|
|
75
|
+
description: 'Global security requirements'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
additionalProperties: false
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
defaultConfig: {
|
|
82
|
+
enabled: true,
|
|
83
|
+
path: '/swagger',
|
|
84
|
+
title: 'FluxStack API',
|
|
85
|
+
description: 'Modern full-stack TypeScript framework with type-safe API endpoints',
|
|
86
|
+
version: '1.0.0',
|
|
87
|
+
tags: [
|
|
88
|
+
{
|
|
89
|
+
name: 'Health',
|
|
90
|
+
description: 'Health check endpoints'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'API',
|
|
94
|
+
description: 'API endpoints'
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
servers: [],
|
|
98
|
+
excludePaths: [],
|
|
99
|
+
securitySchemes: {},
|
|
100
|
+
globalSecurity: []
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
setup: async (context: PluginContext) => {
|
|
104
|
+
const config = getPluginConfig(context)
|
|
105
|
+
|
|
106
|
+
if (!config.enabled) {
|
|
107
|
+
context.logger.debug('Swagger plugin disabled by configuration')
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
// Build servers list
|
|
113
|
+
const servers = config.servers.length > 0 ? config.servers : [
|
|
114
|
+
{
|
|
115
|
+
url: `http://${context.config.server.host}:${context.config.server.port}`,
|
|
116
|
+
description: 'Development server'
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
// Add production server if in production
|
|
121
|
+
if (context.utils.isProduction()) {
|
|
122
|
+
servers.push({
|
|
123
|
+
url: 'https://api.example.com', // This would be configured
|
|
124
|
+
description: 'Production server'
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const swaggerConfig = {
|
|
129
|
+
path: config.path,
|
|
130
|
+
documentation: {
|
|
131
|
+
info: {
|
|
132
|
+
title: config.title || context.config.app?.name || 'FluxStack API',
|
|
133
|
+
version: config.version || context.config.app?.version || '1.0.0',
|
|
134
|
+
description: config.description || context.config.app?.description || 'Modern full-stack TypeScript framework with type-safe API endpoints'
|
|
135
|
+
},
|
|
136
|
+
tags: config.tags,
|
|
137
|
+
servers,
|
|
138
|
+
|
|
139
|
+
// Add security schemes if defined
|
|
140
|
+
...(Object.keys(config.securitySchemes).length > 0 && {
|
|
141
|
+
components: {
|
|
142
|
+
securitySchemes: config.securitySchemes
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
|
|
146
|
+
// Add global security if defined
|
|
147
|
+
...(config.globalSecurity.length > 0 && {
|
|
148
|
+
security: config.globalSecurity
|
|
149
|
+
})
|
|
150
|
+
},
|
|
151
|
+
exclude: config.excludePaths,
|
|
152
|
+
swaggerOptions: {
|
|
153
|
+
persistAuthorization: true,
|
|
154
|
+
displayRequestDuration: true,
|
|
155
|
+
filter: true,
|
|
156
|
+
showExtensions: true,
|
|
157
|
+
tryItOutEnabled: true
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
context.app.use(swagger(swaggerConfig))
|
|
162
|
+
|
|
163
|
+
context.logger.debug(`Swagger documentation enabled at ${config.path}`, {
|
|
164
|
+
title: swaggerConfig.documentation.info.title,
|
|
165
|
+
version: swaggerConfig.documentation.info.version,
|
|
166
|
+
servers: servers.length
|
|
167
|
+
})
|
|
168
|
+
} catch (error) {
|
|
169
|
+
context.logger.error('Failed to setup Swagger plugin', { error })
|
|
170
|
+
throw error
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
onServerStart: async (context: PluginContext) => {
|
|
175
|
+
const config = getPluginConfig(context)
|
|
176
|
+
|
|
177
|
+
if (config.enabled) {
|
|
178
|
+
const swaggerUrl = `http://${context.config.server.host}:${context.config.server.port}${config.path}`
|
|
179
|
+
context.logger.debug(`Swagger documentation available at: ${swaggerUrl}`)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Helper function to get plugin config from context
|
|
185
|
+
function getPluginConfig(context: PluginContext) {
|
|
186
|
+
// In a real implementation, this would get the config from the plugin context
|
|
187
|
+
// For now, merge default config with any provided config
|
|
188
|
+
const pluginConfig = context.config.plugins.config?.swagger || {}
|
|
189
|
+
return { ...swaggerPlugin.defaultConfig, ...pluginConfig }
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Example usage for security configuration:
|
|
193
|
+
//
|
|
194
|
+
// To enable security in your FluxStack app, configure like this:
|
|
195
|
+
//
|
|
196
|
+
// plugins: {
|
|
197
|
+
// config: {
|
|
198
|
+
// swagger: {
|
|
199
|
+
// securitySchemes: {
|
|
200
|
+
// bearerAuth: {
|
|
201
|
+
// type: 'http',
|
|
202
|
+
// scheme: 'bearer',
|
|
203
|
+
// bearerFormat: 'JWT'
|
|
204
|
+
// },
|
|
205
|
+
// apiKeyAuth: {
|
|
206
|
+
// type: 'apiKey',
|
|
207
|
+
// in: 'header',
|
|
208
|
+
// name: 'X-API-Key'
|
|
209
|
+
// }
|
|
210
|
+
// },
|
|
211
|
+
// globalSecurity: [
|
|
212
|
+
// { bearerAuth: [] } // Apply JWT auth globally
|
|
213
|
+
// ]
|
|
214
|
+
// }
|
|
215
|
+
// }
|
|
216
|
+
// }
|
|
217
|
+
//
|
|
218
|
+
// Then in your routes, you can override per endpoint:
|
|
219
|
+
// app.get('/public', handler, {
|
|
220
|
+
// detail: { security: [] } // No auth required
|
|
221
|
+
// })
|
|
222
|
+
//
|
|
223
|
+
// app.get('/private', handler, {
|
|
224
|
+
// detail: {
|
|
225
|
+
// security: [{ apiKeyAuth: [] }] // API key required
|
|
226
|
+
// }
|
|
227
|
+
// })
|
|
228
|
+
|
|
229
229
|
export default swaggerPlugin
|