create-fluxstack 1.0.1 → 1.0.2

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.
Files changed (100) hide show
  1. package/create-fluxstack.ts +2 -3
  2. package/package.json +1 -1
  3. package/.env +0 -30
  4. package/LICENSE +0 -21
  5. package/app/client/README.md +0 -69
  6. package/app/client/frontend-only.ts +0 -12
  7. package/app/client/index.html +0 -13
  8. package/app/client/public/vite.svg +0 -1
  9. package/app/client/src/App.css +0 -883
  10. package/app/client/src/App.tsx +0 -669
  11. package/app/client/src/assets/react.svg +0 -1
  12. package/app/client/src/components/TestPage.tsx +0 -453
  13. package/app/client/src/index.css +0 -51
  14. package/app/client/src/lib/eden-api.ts +0 -110
  15. package/app/client/src/main.tsx +0 -10
  16. package/app/client/src/vite-env.d.ts +0 -1
  17. package/app/client/tsconfig.app.json +0 -43
  18. package/app/client/tsconfig.json +0 -7
  19. package/app/client/tsconfig.node.json +0 -25
  20. package/app/server/app.ts +0 -10
  21. package/app/server/backend-only.ts +0 -15
  22. package/app/server/controllers/users.controller.ts +0 -69
  23. package/app/server/index.ts +0 -104
  24. package/app/server/routes/index.ts +0 -25
  25. package/app/server/routes/users.routes.ts +0 -121
  26. package/app/server/types/index.ts +0 -1
  27. package/app/shared/types/index.ts +0 -18
  28. package/bun.lock +0 -1053
  29. package/core/__tests__/integration.test.ts +0 -227
  30. package/core/build/index.ts +0 -186
  31. package/core/cli/command-registry.ts +0 -334
  32. package/core/cli/index.ts +0 -394
  33. package/core/cli/plugin-discovery.ts +0 -200
  34. package/core/client/standalone.ts +0 -57
  35. package/core/config/__tests__/config-loader.test.ts +0 -591
  36. package/core/config/__tests__/config-merger.test.ts +0 -657
  37. package/core/config/__tests__/env-converter.test.ts +0 -372
  38. package/core/config/__tests__/env-processor.test.ts +0 -431
  39. package/core/config/__tests__/env.test.ts +0 -452
  40. package/core/config/__tests__/integration.test.ts +0 -418
  41. package/core/config/__tests__/loader.test.ts +0 -331
  42. package/core/config/__tests__/schema.test.ts +0 -129
  43. package/core/config/__tests__/validator.test.ts +0 -318
  44. package/core/config/env-dynamic.ts +0 -326
  45. package/core/config/env.ts +0 -597
  46. package/core/config/index.ts +0 -317
  47. package/core/config/loader.ts +0 -546
  48. package/core/config/runtime-config.ts +0 -322
  49. package/core/config/schema.ts +0 -694
  50. package/core/config/validator.ts +0 -540
  51. package/core/framework/__tests__/server.test.ts +0 -233
  52. package/core/framework/client.ts +0 -132
  53. package/core/framework/index.ts +0 -8
  54. package/core/framework/server.ts +0 -501
  55. package/core/framework/types.ts +0 -63
  56. package/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  57. package/core/plugins/__tests__/manager.test.ts +0 -398
  58. package/core/plugins/__tests__/monitoring.test.ts +0 -401
  59. package/core/plugins/__tests__/registry.test.ts +0 -335
  60. package/core/plugins/built-in/index.ts +0 -142
  61. package/core/plugins/built-in/logger/index.ts +0 -180
  62. package/core/plugins/built-in/monitoring/README.md +0 -193
  63. package/core/plugins/built-in/monitoring/index.ts +0 -912
  64. package/core/plugins/built-in/static/index.ts +0 -289
  65. package/core/plugins/built-in/swagger/index.ts +0 -229
  66. package/core/plugins/built-in/vite/index.ts +0 -316
  67. package/core/plugins/config.ts +0 -348
  68. package/core/plugins/discovery.ts +0 -350
  69. package/core/plugins/executor.ts +0 -351
  70. package/core/plugins/index.ts +0 -195
  71. package/core/plugins/manager.ts +0 -583
  72. package/core/plugins/registry.ts +0 -424
  73. package/core/plugins/types.ts +0 -254
  74. package/core/server/framework.ts +0 -123
  75. package/core/server/index.ts +0 -8
  76. package/core/server/plugins/database.ts +0 -182
  77. package/core/server/plugins/logger.ts +0 -47
  78. package/core/server/plugins/swagger.ts +0 -34
  79. package/core/server/standalone.ts +0 -91
  80. package/core/templates/create-project.ts +0 -455
  81. package/core/types/api.ts +0 -169
  82. package/core/types/build.ts +0 -174
  83. package/core/types/config.ts +0 -68
  84. package/core/types/index.ts +0 -127
  85. package/core/types/plugin.ts +0 -94
  86. package/core/utils/__tests__/errors.test.ts +0 -139
  87. package/core/utils/__tests__/helpers.test.ts +0 -297
  88. package/core/utils/__tests__/logger.test.ts +0 -141
  89. package/core/utils/env-runtime-v2.ts +0 -232
  90. package/core/utils/env-runtime.ts +0 -252
  91. package/core/utils/errors/codes.ts +0 -115
  92. package/core/utils/errors/handlers.ts +0 -63
  93. package/core/utils/errors/index.ts +0 -81
  94. package/core/utils/helpers.ts +0 -180
  95. package/core/utils/index.ts +0 -18
  96. package/core/utils/logger/index.ts +0 -161
  97. package/core/utils/logger.ts +0 -106
  98. package/core/utils/monitoring/index.ts +0 -212
  99. package/tsconfig.json +0 -51
  100. package/vite.config.ts +0 -42
@@ -1,233 +0,0 @@
1
- /**
2
- * Tests for FluxStack Framework Server
3
- */
4
-
5
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
6
- import { FluxStackFramework } from '../server'
7
- import type { Plugin } from '../../plugins/types'
8
-
9
- // Mock dependencies
10
- vi.mock('../../config', () => ({
11
- getConfigSync: vi.fn(() => ({
12
- server: {
13
- port: 3000,
14
- apiPrefix: '/api',
15
- cors: {
16
- origins: ['*'],
17
- methods: ['GET', 'POST'],
18
- headers: ['Content-Type'],
19
- credentials: false
20
- }
21
- },
22
- app: {
23
- name: 'test-app',
24
- version: '1.0.0'
25
- }
26
- })),
27
- getEnvironmentInfo: vi.fn(() => ({
28
- isDevelopment: true,
29
- isProduction: false,
30
- isTest: true,
31
- name: 'test'
32
- }))
33
- }))
34
-
35
- vi.mock('../../utils/logger', () => ({
36
- logger: {
37
- framework: vi.fn(),
38
- warn: vi.fn(),
39
- error: vi.fn(),
40
- child: vi.fn(() => ({
41
- framework: vi.fn(),
42
- warn: vi.fn(),
43
- error: vi.fn()
44
- }))
45
- }
46
- }))
47
-
48
- vi.mock('../../utils/errors/handlers', () => ({
49
- createErrorHandler: vi.fn(() => vi.fn())
50
- }))
51
-
52
- vi.mock('elysia', () => ({
53
- Elysia: vi.fn(() => ({
54
- onRequest: vi.fn().mockReturnThis(),
55
- onAfterHandle: vi.fn().mockReturnThis(),
56
- onError: vi.fn().mockReturnThis(),
57
- options: vi.fn().mockReturnThis(),
58
- use: vi.fn().mockReturnThis(),
59
- listen: vi.fn((_port, callback) => {
60
- if (callback) callback()
61
- })
62
- }))
63
- }))
64
-
65
- describe('FluxStackFramework', () => {
66
- let framework: FluxStackFramework
67
-
68
- beforeEach(() => {
69
- framework = new FluxStackFramework()
70
- })
71
-
72
- afterEach(() => {
73
- vi.clearAllMocks()
74
- })
75
-
76
- describe('Constructor', () => {
77
- it('should initialize framework with default config', () => {
78
- expect(framework).toBeInstanceOf(FluxStackFramework)
79
- expect(framework.getContext()).toBeDefined()
80
- expect(framework.getApp()).toBeDefined()
81
- expect(framework.getPluginRegistry()).toBeDefined()
82
- })
83
-
84
- it('should initialize framework with custom config', () => {
85
- const customConfig = {
86
- server: {
87
- port: 4000,
88
- host: 'localhost',
89
- apiPrefix: '/custom-api',
90
- cors: {
91
- origins: ['*'],
92
- methods: ['GET', 'POST'],
93
- headers: ['Content-Type'],
94
- credentials: false,
95
- maxAge: 86400
96
- },
97
- middleware: []
98
- }
99
- }
100
-
101
- const customFramework = new FluxStackFramework(customConfig)
102
- const context = customFramework.getContext()
103
-
104
- expect(context.config.server.port).toBe(4000)
105
- expect(context.config.server.apiPrefix).toBe('/custom-api')
106
- })
107
-
108
- it('should set up context correctly', () => {
109
- const context = framework.getContext()
110
-
111
- expect(context.isDevelopment).toBe(true)
112
- expect(context.isProduction).toBe(false)
113
- expect(context.isTest).toBe(true)
114
- expect(context.environment).toBe('test')
115
- })
116
- })
117
-
118
- describe('Plugin Management', () => {
119
- it('should register plugins successfully', () => {
120
- const mockPlugin: Plugin = {
121
- name: 'test-plugin',
122
- setup: vi.fn()
123
- }
124
-
125
- expect(() => framework.use(mockPlugin)).not.toThrow()
126
- expect(framework.getPluginRegistry().get('test-plugin')).toBe(mockPlugin)
127
- })
128
-
129
- it('should throw error when registering duplicate plugin', () => {
130
- const mockPlugin: Plugin = {
131
- name: 'duplicate-plugin',
132
- setup: vi.fn()
133
- }
134
-
135
- framework.use(mockPlugin)
136
- expect(() => framework.use(mockPlugin)).toThrow()
137
- })
138
-
139
- it('should validate plugin dependencies', async () => {
140
- const pluginA: Plugin = {
141
- name: 'plugin-a',
142
- setup: vi.fn()
143
- }
144
-
145
- const pluginB: Plugin = {
146
- name: 'plugin-b',
147
- dependencies: ['plugin-a'],
148
- setup: vi.fn()
149
- }
150
-
151
- framework.use(pluginA)
152
- framework.use(pluginB)
153
-
154
- await expect(framework.start()).resolves.not.toThrow()
155
- })
156
-
157
- it('should throw error for missing dependencies', async () => {
158
- const pluginWithMissingDep: Plugin = {
159
- name: 'plugin-with-missing-dep',
160
- dependencies: ['non-existent-plugin'],
161
- setup: vi.fn()
162
- }
163
-
164
- framework.use(pluginWithMissingDep)
165
- await expect(framework.start()).rejects.toThrow()
166
- })
167
- })
168
-
169
- describe('Lifecycle Management', () => {
170
- it('should start framework successfully', async () => {
171
- const mockPlugin: Plugin = {
172
- name: 'lifecycle-plugin',
173
- setup: vi.fn(),
174
- onServerStart: vi.fn()
175
- }
176
-
177
- framework.use(mockPlugin)
178
- await framework.start()
179
-
180
- expect(mockPlugin.setup).toHaveBeenCalled()
181
- expect(mockPlugin.onServerStart).toHaveBeenCalled()
182
- })
183
-
184
- it('should stop framework successfully', async () => {
185
- const mockPlugin: Plugin = {
186
- name: 'lifecycle-plugin',
187
- setup: vi.fn(),
188
- onServerStart: vi.fn(),
189
- onServerStop: vi.fn()
190
- }
191
-
192
- framework.use(mockPlugin)
193
- await framework.start()
194
- await framework.stop()
195
-
196
- expect(mockPlugin.onServerStop).toHaveBeenCalled()
197
- })
198
-
199
- it('should not start framework twice', async () => {
200
- await framework.start()
201
- await framework.start() // Should not throw or cause issues
202
-
203
- // Should log warning about already started
204
- const { logger } = await import('../../utils/logger')
205
- expect(logger.warn).toHaveBeenCalled()
206
- })
207
-
208
- it('should handle plugin setup errors', async () => {
209
- const errorPlugin: Plugin = {
210
- name: 'error-plugin',
211
- setup: vi.fn().mockRejectedValue(new Error('Setup failed'))
212
- }
213
-
214
- framework.use(errorPlugin)
215
- await expect(framework.start()).rejects.toThrow('Setup failed')
216
- })
217
- })
218
-
219
- describe('Routes', () => {
220
- it('should add routes to the app', () => {
221
- const mockRouteModule = { get: vi.fn() }
222
-
223
- expect(() => framework.routes(mockRouteModule)).not.toThrow()
224
- })
225
- })
226
-
227
- describe('Error Handling', () => {
228
- it('should set up error handling', async () => {
229
- const { createErrorHandler } = await import('../../utils/errors/handlers')
230
- expect(createErrorHandler).toHaveBeenCalled()
231
- })
232
- })
233
- })
@@ -1,132 +0,0 @@
1
- /**
2
- * FluxStack Client Framework Utilities
3
- * Provides client-side utilities and integrations
4
- */
5
-
6
- import type { FluxStackConfig } from "../types"
7
-
8
- export interface ClientFrameworkOptions {
9
- config: FluxStackConfig
10
- baseUrl?: string
11
- timeout?: number
12
- retries?: number
13
- }
14
-
15
- export class FluxStackClient {
16
- private config: FluxStackConfig
17
- private baseUrl: string
18
- private timeout: number
19
- private retries: number
20
-
21
- constructor(options: ClientFrameworkOptions) {
22
- this.config = options.config
23
- this.baseUrl = options.baseUrl || `http://localhost:${options.config.server.port}`
24
- this.timeout = options.timeout || 10000
25
- this.retries = options.retries || 3
26
- }
27
-
28
- // Create a configured fetch client
29
- createFetchClient() {
30
- return async (url: string, options: RequestInit = {}) => {
31
- const fullUrl = url.startsWith('http') ? url : `${this.baseUrl}${url}`
32
-
33
- const requestOptions: RequestInit = {
34
- ...options,
35
- headers: {
36
- 'Content-Type': 'application/json',
37
- ...options.headers
38
- }
39
- }
40
-
41
- // Add timeout
42
- const controller = new AbortController()
43
- const timeoutId = setTimeout(() => controller.abort(), this.timeout)
44
- requestOptions.signal = controller.signal
45
-
46
- try {
47
- const response = await fetch(fullUrl, requestOptions)
48
- clearTimeout(timeoutId)
49
-
50
- if (!response.ok) {
51
- throw new Error(`HTTP ${response.status}: ${response.statusText}`)
52
- }
53
-
54
- return response
55
- } catch (error) {
56
- clearTimeout(timeoutId)
57
- throw error
58
- }
59
- }
60
- }
61
-
62
- // Create API client with retry logic
63
- createApiClient() {
64
- const fetchClient = this.createFetchClient()
65
-
66
- return {
67
- get: async <T>(url: string): Promise<T> => {
68
- return this.withRetry(async () => {
69
- const response = await fetchClient(url, { method: 'GET' })
70
- return response.json()
71
- })
72
- },
73
-
74
- post: async <T>(url: string, data: any): Promise<T> => {
75
- return this.withRetry(async () => {
76
- const response = await fetchClient(url, {
77
- method: 'POST',
78
- body: JSON.stringify(data)
79
- })
80
- return response.json()
81
- })
82
- },
83
-
84
- put: async <T>(url: string, data: any): Promise<T> => {
85
- return this.withRetry(async () => {
86
- const response = await fetchClient(url, {
87
- method: 'PUT',
88
- body: JSON.stringify(data)
89
- })
90
- return response.json()
91
- })
92
- },
93
-
94
- delete: async <T>(url: string): Promise<T> => {
95
- return this.withRetry(async () => {
96
- const response = await fetchClient(url, { method: 'DELETE' })
97
- return response.json()
98
- })
99
- }
100
- }
101
- }
102
-
103
- private async withRetry<T>(fn: () => Promise<T>): Promise<T> {
104
- let lastError: Error
105
-
106
- for (let attempt = 1; attempt <= this.retries; attempt++) {
107
- try {
108
- return await fn()
109
- } catch (error) {
110
- lastError = error as Error
111
-
112
- if (attempt === this.retries) {
113
- throw lastError
114
- }
115
-
116
- // Exponential backoff
117
- const delay = Math.min(1000 * Math.pow(2, attempt - 1), 10000)
118
- await new Promise(resolve => setTimeout(resolve, delay))
119
- }
120
- }
121
-
122
- throw lastError!
123
- }
124
-
125
- getConfig(): FluxStackConfig {
126
- return this.config
127
- }
128
-
129
- getBaseUrl(): string {
130
- return this.baseUrl
131
- }
132
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * FluxStack Framework Core
3
- * Main exports for the framework components
4
- */
5
-
6
- export { FluxStackFramework } from "./server"
7
- export { FluxStackClient } from "./client"
8
- export * from "./types"