create-fluxstack 1.0.5 → 1.0.7

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 (406) hide show
  1. package/.claude/settings.local.json +2 -1
  2. package/create-fluxstack.ts +1 -0
  3. package/package.json +3 -3
  4. package/ENV_TESTING_REPORT.md +0 -292
  5. package/FRAMEWORK_ROADMAP.md +0 -183
  6. package/FRONTEND_TESTS_README.md +0 -287
  7. package/TEST_RESULTS.md +0 -130
  8. package/docs/dynamic-environment-variables.md +0 -380
  9. package/examples/dynamic-env-usage.ts +0 -283
  10. package/examples/hybrid-env-strategy.ts +0 -212
  11. package/examples/simplified-env-usage.ts +0 -251
  12. package/meu-app-teste/README.md +0 -44
  13. package/meu-app-teste/app/client/README.md +0 -69
  14. package/meu-app-teste/app/client/frontend-only.ts +0 -12
  15. package/meu-app-teste/app/client/index.html +0 -13
  16. package/meu-app-teste/app/client/public/vite.svg +0 -1
  17. package/meu-app-teste/app/client/src/App.css +0 -883
  18. package/meu-app-teste/app/client/src/App.tsx +0 -669
  19. package/meu-app-teste/app/client/src/assets/react.svg +0 -1
  20. package/meu-app-teste/app/client/src/components/TestPage.tsx +0 -453
  21. package/meu-app-teste/app/client/src/index.css +0 -51
  22. package/meu-app-teste/app/client/src/lib/eden-api.ts +0 -110
  23. package/meu-app-teste/app/client/src/main.tsx +0 -10
  24. package/meu-app-teste/app/client/src/vite-env.d.ts +0 -1
  25. package/meu-app-teste/app/client/tsconfig.app.json +0 -43
  26. package/meu-app-teste/app/client/tsconfig.json +0 -7
  27. package/meu-app-teste/app/client/tsconfig.node.json +0 -25
  28. package/meu-app-teste/app/server/app.ts +0 -10
  29. package/meu-app-teste/app/server/backend-only.ts +0 -15
  30. package/meu-app-teste/app/server/controllers/users.controller.ts +0 -69
  31. package/meu-app-teste/app/server/index.ts +0 -104
  32. package/meu-app-teste/app/server/routes/index.ts +0 -25
  33. package/meu-app-teste/app/server/routes/users.routes.ts +0 -121
  34. package/meu-app-teste/app/server/types/index.ts +0 -1
  35. package/meu-app-teste/app/shared/types/index.ts +0 -18
  36. package/meu-app-teste/bun.lock +0 -1053
  37. package/meu-app-teste/core/__tests__/integration.test.ts +0 -227
  38. package/meu-app-teste/core/build/index.ts +0 -186
  39. package/meu-app-teste/core/cli/command-registry.ts +0 -334
  40. package/meu-app-teste/core/cli/index.ts +0 -394
  41. package/meu-app-teste/core/cli/plugin-discovery.ts +0 -200
  42. package/meu-app-teste/core/client/standalone.ts +0 -57
  43. package/meu-app-teste/core/config/__tests__/config-loader.test.ts +0 -591
  44. package/meu-app-teste/core/config/__tests__/config-merger.test.ts +0 -657
  45. package/meu-app-teste/core/config/__tests__/env-converter.test.ts +0 -372
  46. package/meu-app-teste/core/config/__tests__/env-processor.test.ts +0 -431
  47. package/meu-app-teste/core/config/__tests__/env.test.ts +0 -452
  48. package/meu-app-teste/core/config/__tests__/integration.test.ts +0 -418
  49. package/meu-app-teste/core/config/__tests__/loader.test.ts +0 -331
  50. package/meu-app-teste/core/config/__tests__/schema.test.ts +0 -129
  51. package/meu-app-teste/core/config/__tests__/validator.test.ts +0 -318
  52. package/meu-app-teste/core/config/env-dynamic.ts +0 -326
  53. package/meu-app-teste/core/config/env.ts +0 -597
  54. package/meu-app-teste/core/config/index.ts +0 -317
  55. package/meu-app-teste/core/config/loader.ts +0 -546
  56. package/meu-app-teste/core/config/runtime-config.ts +0 -322
  57. package/meu-app-teste/core/config/schema.ts +0 -694
  58. package/meu-app-teste/core/config/validator.ts +0 -540
  59. package/meu-app-teste/core/framework/__tests__/server.test.ts +0 -233
  60. package/meu-app-teste/core/framework/client.ts +0 -132
  61. package/meu-app-teste/core/framework/index.ts +0 -8
  62. package/meu-app-teste/core/framework/server.ts +0 -501
  63. package/meu-app-teste/core/framework/types.ts +0 -63
  64. package/meu-app-teste/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  65. package/meu-app-teste/core/plugins/__tests__/manager.test.ts +0 -398
  66. package/meu-app-teste/core/plugins/__tests__/monitoring.test.ts +0 -401
  67. package/meu-app-teste/core/plugins/__tests__/registry.test.ts +0 -335
  68. package/meu-app-teste/core/plugins/built-in/index.ts +0 -142
  69. package/meu-app-teste/core/plugins/built-in/logger/index.ts +0 -180
  70. package/meu-app-teste/core/plugins/built-in/monitoring/README.md +0 -193
  71. package/meu-app-teste/core/plugins/built-in/monitoring/index.ts +0 -912
  72. package/meu-app-teste/core/plugins/built-in/static/index.ts +0 -289
  73. package/meu-app-teste/core/plugins/built-in/swagger/index.ts +0 -229
  74. package/meu-app-teste/core/plugins/built-in/vite/index.ts +0 -316
  75. package/meu-app-teste/core/plugins/config.ts +0 -348
  76. package/meu-app-teste/core/plugins/discovery.ts +0 -350
  77. package/meu-app-teste/core/plugins/executor.ts +0 -351
  78. package/meu-app-teste/core/plugins/index.ts +0 -195
  79. package/meu-app-teste/core/plugins/manager.ts +0 -583
  80. package/meu-app-teste/core/plugins/registry.ts +0 -424
  81. package/meu-app-teste/core/plugins/types.ts +0 -254
  82. package/meu-app-teste/core/server/framework.ts +0 -123
  83. package/meu-app-teste/core/server/index.ts +0 -8
  84. package/meu-app-teste/core/server/plugins/database.ts +0 -182
  85. package/meu-app-teste/core/server/plugins/logger.ts +0 -47
  86. package/meu-app-teste/core/server/plugins/swagger.ts +0 -34
  87. package/meu-app-teste/core/server/standalone.ts +0 -91
  88. package/meu-app-teste/core/templates/create-project.ts +0 -455
  89. package/meu-app-teste/core/types/api.ts +0 -169
  90. package/meu-app-teste/core/types/build.ts +0 -174
  91. package/meu-app-teste/core/types/config.ts +0 -68
  92. package/meu-app-teste/core/types/index.ts +0 -127
  93. package/meu-app-teste/core/types/plugin.ts +0 -94
  94. package/meu-app-teste/core/utils/__tests__/errors.test.ts +0 -139
  95. package/meu-app-teste/core/utils/__tests__/helpers.test.ts +0 -297
  96. package/meu-app-teste/core/utils/__tests__/logger.test.ts +0 -141
  97. package/meu-app-teste/core/utils/env-runtime-v2.ts +0 -232
  98. package/meu-app-teste/core/utils/env-runtime.ts +0 -252
  99. package/meu-app-teste/core/utils/errors/codes.ts +0 -115
  100. package/meu-app-teste/core/utils/errors/handlers.ts +0 -63
  101. package/meu-app-teste/core/utils/errors/index.ts +0 -81
  102. package/meu-app-teste/core/utils/helpers.ts +0 -180
  103. package/meu-app-teste/core/utils/index.ts +0 -18
  104. package/meu-app-teste/core/utils/logger/index.ts +0 -161
  105. package/meu-app-teste/core/utils/logger.ts +0 -106
  106. package/meu-app-teste/core/utils/monitoring/index.ts +0 -212
  107. package/meu-app-teste/package.json +0 -92
  108. package/meu-app-teste/tsconfig.json +0 -51
  109. package/meu-app-teste/vite.config.ts +0 -42
  110. package/my-final-test/README.md +0 -44
  111. package/my-final-test/app/client/README.md +0 -69
  112. package/my-final-test/app/client/frontend-only.ts +0 -12
  113. package/my-final-test/app/client/index.html +0 -13
  114. package/my-final-test/app/client/public/vite.svg +0 -1
  115. package/my-final-test/app/client/src/App.css +0 -883
  116. package/my-final-test/app/client/src/App.tsx +0 -669
  117. package/my-final-test/app/client/src/assets/react.svg +0 -1
  118. package/my-final-test/app/client/src/components/TestPage.tsx +0 -453
  119. package/my-final-test/app/client/src/index.css +0 -51
  120. package/my-final-test/app/client/src/lib/eden-api.ts +0 -110
  121. package/my-final-test/app/client/src/main.tsx +0 -10
  122. package/my-final-test/app/client/src/vite-env.d.ts +0 -1
  123. package/my-final-test/app/client/tsconfig.app.json +0 -43
  124. package/my-final-test/app/client/tsconfig.json +0 -7
  125. package/my-final-test/app/client/tsconfig.node.json +0 -25
  126. package/my-final-test/app/server/app.ts +0 -10
  127. package/my-final-test/app/server/backend-only.ts +0 -15
  128. package/my-final-test/app/server/controllers/users.controller.ts +0 -69
  129. package/my-final-test/app/server/index.ts +0 -104
  130. package/my-final-test/app/server/routes/index.ts +0 -25
  131. package/my-final-test/app/server/routes/users.routes.ts +0 -121
  132. package/my-final-test/app/server/types/index.ts +0 -1
  133. package/my-final-test/app/shared/types/index.ts +0 -18
  134. package/my-final-test/bun.lock +0 -993
  135. package/my-final-test/core/__tests__/integration.test.ts +0 -227
  136. package/my-final-test/core/build/index.ts +0 -186
  137. package/my-final-test/core/cli/command-registry.ts +0 -334
  138. package/my-final-test/core/cli/index.ts +0 -394
  139. package/my-final-test/core/cli/plugin-discovery.ts +0 -200
  140. package/my-final-test/core/client/standalone.ts +0 -57
  141. package/my-final-test/core/config/__tests__/config-loader.test.ts +0 -591
  142. package/my-final-test/core/config/__tests__/config-merger.test.ts +0 -657
  143. package/my-final-test/core/config/__tests__/env-converter.test.ts +0 -372
  144. package/my-final-test/core/config/__tests__/env-processor.test.ts +0 -431
  145. package/my-final-test/core/config/__tests__/env.test.ts +0 -452
  146. package/my-final-test/core/config/__tests__/integration.test.ts +0 -418
  147. package/my-final-test/core/config/__tests__/loader.test.ts +0 -331
  148. package/my-final-test/core/config/__tests__/schema.test.ts +0 -129
  149. package/my-final-test/core/config/__tests__/validator.test.ts +0 -318
  150. package/my-final-test/core/config/env-dynamic.ts +0 -326
  151. package/my-final-test/core/config/env.ts +0 -597
  152. package/my-final-test/core/config/index.ts +0 -317
  153. package/my-final-test/core/config/loader.ts +0 -546
  154. package/my-final-test/core/config/runtime-config.ts +0 -322
  155. package/my-final-test/core/config/schema.ts +0 -694
  156. package/my-final-test/core/config/validator.ts +0 -540
  157. package/my-final-test/core/framework/__tests__/server.test.ts +0 -233
  158. package/my-final-test/core/framework/client.ts +0 -132
  159. package/my-final-test/core/framework/index.ts +0 -8
  160. package/my-final-test/core/framework/server.ts +0 -501
  161. package/my-final-test/core/framework/types.ts +0 -63
  162. package/my-final-test/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  163. package/my-final-test/core/plugins/__tests__/manager.test.ts +0 -398
  164. package/my-final-test/core/plugins/__tests__/monitoring.test.ts +0 -401
  165. package/my-final-test/core/plugins/__tests__/registry.test.ts +0 -335
  166. package/my-final-test/core/plugins/built-in/index.ts +0 -142
  167. package/my-final-test/core/plugins/built-in/logger/index.ts +0 -180
  168. package/my-final-test/core/plugins/built-in/monitoring/README.md +0 -193
  169. package/my-final-test/core/plugins/built-in/monitoring/index.ts +0 -912
  170. package/my-final-test/core/plugins/built-in/static/index.ts +0 -289
  171. package/my-final-test/core/plugins/built-in/swagger/index.ts +0 -229
  172. package/my-final-test/core/plugins/built-in/vite/index.ts +0 -316
  173. package/my-final-test/core/plugins/config.ts +0 -348
  174. package/my-final-test/core/plugins/discovery.ts +0 -350
  175. package/my-final-test/core/plugins/executor.ts +0 -351
  176. package/my-final-test/core/plugins/index.ts +0 -195
  177. package/my-final-test/core/plugins/manager.ts +0 -583
  178. package/my-final-test/core/plugins/registry.ts +0 -424
  179. package/my-final-test/core/plugins/types.ts +0 -254
  180. package/my-final-test/core/server/framework.ts +0 -123
  181. package/my-final-test/core/server/index.ts +0 -8
  182. package/my-final-test/core/server/plugins/database.ts +0 -182
  183. package/my-final-test/core/server/plugins/logger.ts +0 -47
  184. package/my-final-test/core/server/plugins/swagger.ts +0 -34
  185. package/my-final-test/core/server/standalone.ts +0 -91
  186. package/my-final-test/core/templates/create-project.ts +0 -455
  187. package/my-final-test/core/types/api.ts +0 -169
  188. package/my-final-test/core/types/build.ts +0 -174
  189. package/my-final-test/core/types/config.ts +0 -68
  190. package/my-final-test/core/types/index.ts +0 -127
  191. package/my-final-test/core/types/plugin.ts +0 -94
  192. package/my-final-test/core/utils/__tests__/errors.test.ts +0 -139
  193. package/my-final-test/core/utils/__tests__/helpers.test.ts +0 -297
  194. package/my-final-test/core/utils/__tests__/logger.test.ts +0 -141
  195. package/my-final-test/core/utils/env-runtime-v2.ts +0 -232
  196. package/my-final-test/core/utils/env-runtime.ts +0 -252
  197. package/my-final-test/core/utils/errors/codes.ts +0 -115
  198. package/my-final-test/core/utils/errors/handlers.ts +0 -63
  199. package/my-final-test/core/utils/errors/index.ts +0 -81
  200. package/my-final-test/core/utils/helpers.ts +0 -180
  201. package/my-final-test/core/utils/index.ts +0 -18
  202. package/my-final-test/core/utils/logger/index.ts +0 -161
  203. package/my-final-test/core/utils/logger.ts +0 -106
  204. package/my-final-test/core/utils/monitoring/index.ts +0 -212
  205. package/my-final-test/package.json +0 -68
  206. package/my-final-test/tsconfig.json +0 -51
  207. package/my-final-test/vite.config.ts +0 -42
  208. package/publish-setup.md +0 -111
  209. package/teste-corrigido/README.md +0 -44
  210. package/teste-corrigido/app/client/README.md +0 -69
  211. package/teste-corrigido/app/client/frontend-only.ts +0 -12
  212. package/teste-corrigido/app/client/index.html +0 -13
  213. package/teste-corrigido/app/client/public/vite.svg +0 -1
  214. package/teste-corrigido/app/client/src/App.css +0 -883
  215. package/teste-corrigido/app/client/src/App.tsx +0 -669
  216. package/teste-corrigido/app/client/src/assets/react.svg +0 -1
  217. package/teste-corrigido/app/client/src/components/TestPage.tsx +0 -453
  218. package/teste-corrigido/app/client/src/index.css +0 -51
  219. package/teste-corrigido/app/client/src/lib/eden-api.ts +0 -110
  220. package/teste-corrigido/app/client/src/main.tsx +0 -10
  221. package/teste-corrigido/app/client/src/vite-env.d.ts +0 -1
  222. package/teste-corrigido/app/client/tsconfig.app.json +0 -43
  223. package/teste-corrigido/app/client/tsconfig.json +0 -7
  224. package/teste-corrigido/app/client/tsconfig.node.json +0 -25
  225. package/teste-corrigido/app/server/app.ts +0 -10
  226. package/teste-corrigido/app/server/backend-only.ts +0 -15
  227. package/teste-corrigido/app/server/controllers/users.controller.ts +0 -69
  228. package/teste-corrigido/app/server/index.ts +0 -104
  229. package/teste-corrigido/app/server/routes/index.ts +0 -25
  230. package/teste-corrigido/app/server/routes/users.routes.ts +0 -121
  231. package/teste-corrigido/app/server/types/index.ts +0 -1
  232. package/teste-corrigido/app/shared/types/index.ts +0 -18
  233. package/teste-corrigido/bun.lock +0 -1053
  234. package/teste-corrigido/core/__tests__/integration.test.ts +0 -227
  235. package/teste-corrigido/core/build/index.ts +0 -186
  236. package/teste-corrigido/core/cli/command-registry.ts +0 -334
  237. package/teste-corrigido/core/cli/index.ts +0 -394
  238. package/teste-corrigido/core/cli/plugin-discovery.ts +0 -200
  239. package/teste-corrigido/core/client/standalone.ts +0 -57
  240. package/teste-corrigido/core/config/__tests__/config-loader.test.ts +0 -591
  241. package/teste-corrigido/core/config/__tests__/config-merger.test.ts +0 -657
  242. package/teste-corrigido/core/config/__tests__/env-converter.test.ts +0 -372
  243. package/teste-corrigido/core/config/__tests__/env-processor.test.ts +0 -431
  244. package/teste-corrigido/core/config/__tests__/env.test.ts +0 -452
  245. package/teste-corrigido/core/config/__tests__/integration.test.ts +0 -418
  246. package/teste-corrigido/core/config/__tests__/loader.test.ts +0 -331
  247. package/teste-corrigido/core/config/__tests__/schema.test.ts +0 -129
  248. package/teste-corrigido/core/config/__tests__/validator.test.ts +0 -318
  249. package/teste-corrigido/core/config/env-dynamic.ts +0 -326
  250. package/teste-corrigido/core/config/env.ts +0 -597
  251. package/teste-corrigido/core/config/index.ts +0 -317
  252. package/teste-corrigido/core/config/loader.ts +0 -546
  253. package/teste-corrigido/core/config/runtime-config.ts +0 -322
  254. package/teste-corrigido/core/config/schema.ts +0 -694
  255. package/teste-corrigido/core/config/validator.ts +0 -540
  256. package/teste-corrigido/core/framework/__tests__/server.test.ts +0 -233
  257. package/teste-corrigido/core/framework/client.ts +0 -132
  258. package/teste-corrigido/core/framework/index.ts +0 -8
  259. package/teste-corrigido/core/framework/server.ts +0 -501
  260. package/teste-corrigido/core/framework/types.ts +0 -63
  261. package/teste-corrigido/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  262. package/teste-corrigido/core/plugins/__tests__/manager.test.ts +0 -398
  263. package/teste-corrigido/core/plugins/__tests__/monitoring.test.ts +0 -401
  264. package/teste-corrigido/core/plugins/__tests__/registry.test.ts +0 -335
  265. package/teste-corrigido/core/plugins/built-in/index.ts +0 -142
  266. package/teste-corrigido/core/plugins/built-in/logger/index.ts +0 -180
  267. package/teste-corrigido/core/plugins/built-in/monitoring/README.md +0 -193
  268. package/teste-corrigido/core/plugins/built-in/monitoring/index.ts +0 -912
  269. package/teste-corrigido/core/plugins/built-in/static/index.ts +0 -289
  270. package/teste-corrigido/core/plugins/built-in/swagger/index.ts +0 -229
  271. package/teste-corrigido/core/plugins/built-in/vite/index.ts +0 -316
  272. package/teste-corrigido/core/plugins/config.ts +0 -348
  273. package/teste-corrigido/core/plugins/discovery.ts +0 -350
  274. package/teste-corrigido/core/plugins/executor.ts +0 -351
  275. package/teste-corrigido/core/plugins/index.ts +0 -195
  276. package/teste-corrigido/core/plugins/manager.ts +0 -583
  277. package/teste-corrigido/core/plugins/registry.ts +0 -424
  278. package/teste-corrigido/core/plugins/types.ts +0 -254
  279. package/teste-corrigido/core/server/framework.ts +0 -123
  280. package/teste-corrigido/core/server/index.ts +0 -8
  281. package/teste-corrigido/core/server/plugins/database.ts +0 -182
  282. package/teste-corrigido/core/server/plugins/logger.ts +0 -47
  283. package/teste-corrigido/core/server/plugins/swagger.ts +0 -34
  284. package/teste-corrigido/core/server/standalone.ts +0 -91
  285. package/teste-corrigido/core/templates/create-project.ts +0 -455
  286. package/teste-corrigido/core/types/api.ts +0 -169
  287. package/teste-corrigido/core/types/build.ts +0 -174
  288. package/teste-corrigido/core/types/config.ts +0 -68
  289. package/teste-corrigido/core/types/index.ts +0 -127
  290. package/teste-corrigido/core/types/plugin.ts +0 -94
  291. package/teste-corrigido/core/utils/__tests__/errors.test.ts +0 -139
  292. package/teste-corrigido/core/utils/__tests__/helpers.test.ts +0 -297
  293. package/teste-corrigido/core/utils/__tests__/logger.test.ts +0 -141
  294. package/teste-corrigido/core/utils/env-runtime-v2.ts +0 -232
  295. package/teste-corrigido/core/utils/env-runtime.ts +0 -252
  296. package/teste-corrigido/core/utils/errors/codes.ts +0 -115
  297. package/teste-corrigido/core/utils/errors/handlers.ts +0 -63
  298. package/teste-corrigido/core/utils/errors/index.ts +0 -81
  299. package/teste-corrigido/core/utils/helpers.ts +0 -180
  300. package/teste-corrigido/core/utils/index.ts +0 -18
  301. package/teste-corrigido/core/utils/logger/index.ts +0 -161
  302. package/teste-corrigido/core/utils/logger.ts +0 -106
  303. package/teste-corrigido/core/utils/monitoring/index.ts +0 -212
  304. package/teste-corrigido/package-template.json +0 -51
  305. package/teste-corrigido/package.json +0 -51
  306. package/teste-corrigido/tsconfig.json +0 -51
  307. package/teste-corrigido/vite.config.ts +0 -42
  308. package/teste-final-npm/README.md +0 -44
  309. package/teste-final-npm/app/client/README.md +0 -69
  310. package/teste-final-npm/app/client/frontend-only.ts +0 -12
  311. package/teste-final-npm/app/client/index.html +0 -13
  312. package/teste-final-npm/app/client/public/vite.svg +0 -1
  313. package/teste-final-npm/app/client/src/App.css +0 -883
  314. package/teste-final-npm/app/client/src/App.tsx +0 -669
  315. package/teste-final-npm/app/client/src/assets/react.svg +0 -1
  316. package/teste-final-npm/app/client/src/components/TestPage.tsx +0 -453
  317. package/teste-final-npm/app/client/src/index.css +0 -51
  318. package/teste-final-npm/app/client/src/lib/eden-api.ts +0 -110
  319. package/teste-final-npm/app/client/src/main.tsx +0 -10
  320. package/teste-final-npm/app/client/src/vite-env.d.ts +0 -1
  321. package/teste-final-npm/app/client/tsconfig.app.json +0 -43
  322. package/teste-final-npm/app/client/tsconfig.json +0 -7
  323. package/teste-final-npm/app/client/tsconfig.node.json +0 -25
  324. package/teste-final-npm/app/server/app.ts +0 -10
  325. package/teste-final-npm/app/server/backend-only.ts +0 -15
  326. package/teste-final-npm/app/server/controllers/users.controller.ts +0 -69
  327. package/teste-final-npm/app/server/index.ts +0 -104
  328. package/teste-final-npm/app/server/routes/index.ts +0 -25
  329. package/teste-final-npm/app/server/routes/users.routes.ts +0 -121
  330. package/teste-final-npm/app/server/types/index.ts +0 -1
  331. package/teste-final-npm/app/shared/types/index.ts +0 -18
  332. package/teste-final-npm/bun.lock +0 -1053
  333. package/teste-final-npm/core/__tests__/integration.test.ts +0 -227
  334. package/teste-final-npm/core/build/index.ts +0 -186
  335. package/teste-final-npm/core/cli/command-registry.ts +0 -334
  336. package/teste-final-npm/core/cli/index.ts +0 -394
  337. package/teste-final-npm/core/cli/plugin-discovery.ts +0 -200
  338. package/teste-final-npm/core/client/standalone.ts +0 -57
  339. package/teste-final-npm/core/config/__tests__/config-loader.test.ts +0 -591
  340. package/teste-final-npm/core/config/__tests__/config-merger.test.ts +0 -657
  341. package/teste-final-npm/core/config/__tests__/env-converter.test.ts +0 -372
  342. package/teste-final-npm/core/config/__tests__/env-processor.test.ts +0 -431
  343. package/teste-final-npm/core/config/__tests__/env.test.ts +0 -452
  344. package/teste-final-npm/core/config/__tests__/integration.test.ts +0 -418
  345. package/teste-final-npm/core/config/__tests__/loader.test.ts +0 -331
  346. package/teste-final-npm/core/config/__tests__/schema.test.ts +0 -129
  347. package/teste-final-npm/core/config/__tests__/validator.test.ts +0 -318
  348. package/teste-final-npm/core/config/env-dynamic.ts +0 -326
  349. package/teste-final-npm/core/config/env.ts +0 -597
  350. package/teste-final-npm/core/config/index.ts +0 -317
  351. package/teste-final-npm/core/config/loader.ts +0 -546
  352. package/teste-final-npm/core/config/runtime-config.ts +0 -322
  353. package/teste-final-npm/core/config/schema.ts +0 -694
  354. package/teste-final-npm/core/config/validator.ts +0 -540
  355. package/teste-final-npm/core/framework/__tests__/server.test.ts +0 -233
  356. package/teste-final-npm/core/framework/client.ts +0 -132
  357. package/teste-final-npm/core/framework/index.ts +0 -8
  358. package/teste-final-npm/core/framework/server.ts +0 -501
  359. package/teste-final-npm/core/framework/types.ts +0 -63
  360. package/teste-final-npm/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  361. package/teste-final-npm/core/plugins/__tests__/manager.test.ts +0 -398
  362. package/teste-final-npm/core/plugins/__tests__/monitoring.test.ts +0 -401
  363. package/teste-final-npm/core/plugins/__tests__/registry.test.ts +0 -335
  364. package/teste-final-npm/core/plugins/built-in/index.ts +0 -142
  365. package/teste-final-npm/core/plugins/built-in/logger/index.ts +0 -180
  366. package/teste-final-npm/core/plugins/built-in/monitoring/README.md +0 -193
  367. package/teste-final-npm/core/plugins/built-in/monitoring/index.ts +0 -912
  368. package/teste-final-npm/core/plugins/built-in/static/index.ts +0 -289
  369. package/teste-final-npm/core/plugins/built-in/swagger/index.ts +0 -229
  370. package/teste-final-npm/core/plugins/built-in/vite/index.ts +0 -316
  371. package/teste-final-npm/core/plugins/config.ts +0 -348
  372. package/teste-final-npm/core/plugins/discovery.ts +0 -350
  373. package/teste-final-npm/core/plugins/executor.ts +0 -351
  374. package/teste-final-npm/core/plugins/index.ts +0 -195
  375. package/teste-final-npm/core/plugins/manager.ts +0 -583
  376. package/teste-final-npm/core/plugins/registry.ts +0 -424
  377. package/teste-final-npm/core/plugins/types.ts +0 -254
  378. package/teste-final-npm/core/server/framework.ts +0 -123
  379. package/teste-final-npm/core/server/index.ts +0 -8
  380. package/teste-final-npm/core/server/plugins/database.ts +0 -182
  381. package/teste-final-npm/core/server/plugins/logger.ts +0 -47
  382. package/teste-final-npm/core/server/plugins/swagger.ts +0 -34
  383. package/teste-final-npm/core/server/standalone.ts +0 -91
  384. package/teste-final-npm/core/templates/create-project.ts +0 -455
  385. package/teste-final-npm/core/types/api.ts +0 -169
  386. package/teste-final-npm/core/types/build.ts +0 -174
  387. package/teste-final-npm/core/types/config.ts +0 -68
  388. package/teste-final-npm/core/types/index.ts +0 -127
  389. package/teste-final-npm/core/types/plugin.ts +0 -94
  390. package/teste-final-npm/core/utils/__tests__/errors.test.ts +0 -139
  391. package/teste-final-npm/core/utils/__tests__/helpers.test.ts +0 -297
  392. package/teste-final-npm/core/utils/__tests__/logger.test.ts +0 -141
  393. package/teste-final-npm/core/utils/env-runtime-v2.ts +0 -232
  394. package/teste-final-npm/core/utils/env-runtime.ts +0 -252
  395. package/teste-final-npm/core/utils/errors/codes.ts +0 -115
  396. package/teste-final-npm/core/utils/errors/handlers.ts +0 -63
  397. package/teste-final-npm/core/utils/errors/index.ts +0 -81
  398. package/teste-final-npm/core/utils/helpers.ts +0 -180
  399. package/teste-final-npm/core/utils/index.ts +0 -18
  400. package/teste-final-npm/core/utils/logger/index.ts +0 -161
  401. package/teste-final-npm/core/utils/logger.ts +0 -106
  402. package/teste-final-npm/core/utils/monitoring/index.ts +0 -212
  403. package/teste-final-npm/package-template.json +0 -51
  404. package/teste-final-npm/package.json +0 -51
  405. package/teste-final-npm/tsconfig.json +0 -51
  406. package/teste-final-npm/vite.config.ts +0 -42
@@ -1,380 +0,0 @@
1
- # 🔄 Dynamic Environment Variables for FluxStack
2
-
3
- ## 🚨 **Problema Resolvido**
4
-
5
- O **Bun build** fixa valores de `process.env` durante a compilação, impossibilitando mudanças de environment variables em produção sem rebuild.
6
-
7
- ### ❌ **Problema Original**
8
- ```typescript
9
- // Durante build, Bun converte isto:
10
- const port = process.env.PORT || 3000
11
-
12
- // Em isto (valor fixo):
13
- const port = "8080" || 3000 // Fixado no build!
14
- ```
15
-
16
- ### ✅ **Solução FluxStack**
17
- ```typescript
18
- import { env } from '@/core/utils/env-runtime'
19
-
20
- // Sempre dinâmico, mesmo após build:
21
- const port = env.num('PORT', 3000) // 🚀 Funciona em runtime!
22
- ```
23
-
24
- ---
25
-
26
- ## 🛠️ **Como Usar**
27
-
28
- ### **1. Import Básico**
29
- ```typescript
30
- import { env } from '@/core/utils/env-runtime'
31
-
32
- // Métodos disponíveis:
33
- const port = env.num('PORT', 3000) // number
34
- const host = env.get('HOST', 'localhost') // string
35
- const debug = env.bool('DEBUG', false) // boolean
36
- const origins = env.array('CORS_ORIGINS') // string[]
37
- const hasDb = env.has('DATABASE_URL') // boolean
38
- ```
39
-
40
- ### **2. Propriedades Shorthand**
41
- ```typescript
42
- // Acesso direto para vars comuns:
43
- console.log(env.PORT) // number
44
- console.log(env.NODE_ENV) // string
45
- console.log(env.DATABASE_URL) // string | undefined
46
- console.log(env.CORS_ORIGINS) // string[]
47
- ```
48
-
49
- ### **3. Configuração de Servidor**
50
- ```typescript
51
- import { createRuntimeConfig } from '@/core/config/runtime-config'
52
-
53
- const config = createRuntimeConfig({
54
- server: {
55
- port: env.num('PORT', 3000),
56
- host: env.get('HOST', 'localhost')
57
- }
58
- })
59
-
60
- const app = new FluxStackFramework(config)
61
- ```
62
-
63
- ### **4. Diferentes Ambientes**
64
- ```typescript
65
- import { runtimeConfig } from '@/core/config/runtime-config'
66
-
67
- // Auto-detect do ambiente:
68
- const config = runtimeConfig.auto()
69
-
70
- // Ou específico:
71
- const devConfig = runtimeConfig.development()
72
- const prodConfig = runtimeConfig.production()
73
- const testConfig = runtimeConfig.test()
74
- ```
75
-
76
- ---
77
-
78
- ## 🔧 **Migração do Código Existente**
79
-
80
- ### **Antes (Fixado pelo Bun)**
81
- ```typescript
82
- // ❌ Será fixado durante build
83
- const oldConfig = {
84
- port: parseInt(process.env.PORT || '3000'),
85
- dbUrl: process.env.DATABASE_URL,
86
- debug: process.env.DEBUG === 'true',
87
- corsOrigins: process.env.CORS_ORIGINS?.split(',') || ['*'],
88
- enableMonitoring: process.env.MONITORING_ENABLED === 'true'
89
- }
90
- ```
91
-
92
- ### **Depois (Dinâmico)**
93
- ```typescript
94
- // ✅ Sempre dinâmico, mesmo após build
95
- import { env } from '@/core/utils/env-runtime'
96
-
97
- const newConfig = {
98
- port: env.num('PORT', 3000),
99
- dbUrl: env.get('DATABASE_URL'),
100
- debug: env.bool('DEBUG', false),
101
- corsOrigins: env.array('CORS_ORIGINS', ['*']),
102
- enableMonitoring: env.bool('MONITORING_ENABLED', false)
103
- }
104
- ```
105
-
106
- ---
107
-
108
- ## 🏗️ **Configuração Avançada**
109
-
110
- ### **1. Namespaces de Environment**
111
- ```typescript
112
- import { createEnvNamespace } from '@/core/utils/env-runtime'
113
-
114
- // Criar loaders especializados
115
- const dbEnv = createEnvNamespace('DATABASE_')
116
- const redisEnv = createEnvNamespace('REDIS_')
117
- const awsEnv = createEnvNamespace('AWS_')
118
-
119
- // Uso:
120
- const dbConfig = {
121
- url: dbEnv.get('URL'), // DATABASE_URL
122
- host: dbEnv.get('HOST'), // DATABASE_HOST
123
- port: dbEnv.getNumber('PORT') // DATABASE_PORT
124
- }
125
- ```
126
-
127
- ### **2. Validação de Environment**
128
- ```typescript
129
- import { envValidation } from '@/core/utils/env-runtime'
130
-
131
- // Validar vars obrigatórias
132
- envValidation.require(['NODE_ENV', 'DATABASE_URL'])
133
-
134
- // Validar formato
135
- envValidation.validate('DATABASE_URL',
136
- (url) => url.includes('://'),
137
- 'DATABASE_URL deve ser uma URL válida'
138
- )
139
- ```
140
-
141
- ### **3. Configuração Condicional**
142
- ```typescript
143
- import { env } from '@/core/utils/env-runtime'
144
-
145
- export function createServerConfig() {
146
- const config = {
147
- port: env.num('PORT', 3000),
148
-
149
- // Database apenas se configurado
150
- ...(env.has('DATABASE_URL') && {
151
- database: {
152
- url: env.get('DATABASE_URL'),
153
- ssl: env.bool('DB_SSL', env.get('NODE_ENV') === 'production')
154
- }
155
- }),
156
-
157
- // Features baseadas no ambiente
158
- features: {
159
- swagger: env.bool('ENABLE_SWAGGER', env.get('NODE_ENV') !== 'production'),
160
- monitoring: env.bool('ENABLE_MONITORING', env.get('NODE_ENV') === 'production')
161
- }
162
- }
163
-
164
- return config
165
- }
166
- ```
167
-
168
- ---
169
-
170
- ## 🚀 **Integração com FluxStack**
171
-
172
- ### **1. Servidor com Env Dinâmico**
173
- ```typescript
174
- import { FluxStackFramework } from '@/core/framework/server'
175
- import { createRuntimeConfig } from '@/core/config/runtime-config'
176
- import { env } from '@/core/utils/env-runtime'
177
-
178
- export async function startServer() {
179
- // Configuração dinâmica
180
- const config = createRuntimeConfig()
181
-
182
- // Framework com env dinâmico
183
- const app = new FluxStackFramework(config)
184
-
185
- // Plugins condicionais
186
- if (env.bool('ENABLE_SWAGGER', true)) {
187
- app.use(swaggerPlugin)
188
- }
189
-
190
- if (env.bool('ENABLE_MONITORING', false)) {
191
- app.use(monitoringPlugin)
192
- }
193
-
194
- await app.listen()
195
-
196
- console.log(`🚀 Server running on port ${env.num('PORT', 3000)}`)
197
- }
198
- ```
199
-
200
- ### **2. Build Configuration**
201
- ```typescript
202
- // No fluxstack.config.ts
203
- import { env } from '@/core/utils/env-runtime'
204
-
205
- export const config = {
206
- app: {
207
- name: env.get('FLUXSTACK_APP_NAME', 'my-app'),
208
- version: env.get('FLUXSTACK_APP_VERSION', '1.0.0')
209
- },
210
-
211
- server: {
212
- port: env.num('PORT', 3000),
213
- host: env.get('HOST', 'localhost'),
214
- cors: {
215
- origins: env.array('CORS_ORIGINS', ['*'])
216
- }
217
- },
218
-
219
- build: {
220
- target: env.get('BUILD_TARGET', 'bun'),
221
- outDir: env.get('BUILD_OUTDIR', 'dist'),
222
- optimization: {
223
- minify: env.bool('BUILD_MINIFY', env.get('NODE_ENV') === 'production')
224
- }
225
- }
226
- }
227
- ```
228
-
229
- ---
230
-
231
- ## 🧪 **Testando com Env Dinâmico**
232
-
233
- ### **1. Configuração de Teste**
234
- ```typescript
235
- import { runtimeConfig } from '@/core/config/runtime-config'
236
-
237
- // Configuração isolada para testes
238
- const testConfig = runtimeConfig.test()
239
-
240
- // Ou com overrides específicos
241
- const config = runtimeConfig.auto({
242
- server: { port: 0 }, // Porta aleatória
243
- database: { url: 'sqlite://memory:' }
244
- })
245
- ```
246
-
247
- ### **2. Mock de Environment Variables**
248
- ```typescript
249
- import { withTestEnv } from '@/examples/dynamic-env-usage'
250
-
251
- test('server configuration with custom env', () => {
252
- withTestEnv({
253
- 'PORT': '9000',
254
- 'NODE_ENV': 'test',
255
- 'DEBUG': 'true'
256
- }, () => {
257
- const config = createServerConfig()
258
- expect(config.port).toBe(9000)
259
- expect(config.debug).toBe(true)
260
- })
261
- })
262
- ```
263
-
264
- ---
265
-
266
- ## 📦 **Deploy e Produção**
267
-
268
- ### **1. Docker com Env Dinâmico**
269
- ```dockerfile
270
- # Dockerfile
271
- FROM oven/bun:1.1-alpine
272
-
273
- WORKDIR /app
274
- COPY . .
275
-
276
- # Build com env dinâmico funcionando
277
- RUN bun run build
278
-
279
- # Environment variables não fixadas no build
280
- ENV NODE_ENV=production
281
- ENV PORT=3000
282
-
283
- CMD ["bun", "run", "dist/index.js"]
284
- ```
285
-
286
- ### **2. Docker Compose**
287
- ```yaml
288
- # docker-compose.yml
289
- version: '3.8'
290
- services:
291
- app:
292
- build: .
293
- ports:
294
- - "${PORT:-3000}:${PORT:-3000}"
295
- environment:
296
- - NODE_ENV=production
297
- - PORT=${PORT:-3000}
298
- - DATABASE_URL=${DATABASE_URL}
299
- - JWT_SECRET=${JWT_SECRET}
300
- - CORS_ORIGINS=${CORS_ORIGINS:-*}
301
- - ENABLE_MONITORING=${ENABLE_MONITORING:-true}
302
- ```
303
-
304
- ### **3. Deploy com Variáveis Dinâmicas**
305
- ```bash
306
- # Build uma vez
307
- bun run build
308
-
309
- # Deploy em diferentes ambientes (sem rebuild!)
310
- NODE_ENV=staging PORT=4000 bun run dist/index.js
311
- NODE_ENV=production PORT=8080 DATABASE_URL=postgres://... bun run dist/index.js
312
- ```
313
-
314
- ---
315
-
316
- ## ⚡ **Performance e Compatibilidade**
317
-
318
- ### **Overhead**
319
- - **Mínimo**: Apenas uma verificação extra por acesso
320
- - **Cache**: Valores são cached dentro da mesma execução
321
- - **Bun.env**: Usa Bun.env quando disponível (mais rápido)
322
-
323
- ### **Compatibilidade**
324
- - ✅ **Bun runtime**: Usa `Bun.env` otimizado
325
- - ✅ **Node.js**: Fallback para `process.env`
326
- - ✅ **Build tools**: Resistente a otimizações
327
- - ✅ **Testing**: Funciona com mocks
328
-
329
- ### **Fallbacks**
330
- 1. `Bun.env` (mais rápido no Bun)
331
- 2. `process.env` (Node.js/fallback)
332
- 3. `eval('process')` (edge cases)
333
-
334
- ---
335
-
336
- ## 🔍 **Debugging**
337
-
338
- ### **Ver Todas as Environment Variables**
339
- ```typescript
340
- import { env } from '@/core/utils/env-runtime'
341
-
342
- // Listar todas as env vars
343
- console.log(env.all())
344
-
345
- // Verificar se existe
346
- if (env.has('DATABASE_URL')) {
347
- console.log('Database configured')
348
- }
349
-
350
- // Debug de configuração
351
- console.log('🔧 Current config:')
352
- console.log(` NODE_ENV: ${env.get('NODE_ENV')}`)
353
- console.log(` PORT: ${env.num('PORT', 3000)}`)
354
- console.log(` DEBUG: ${env.bool('DEBUG')}`)
355
- ```
356
-
357
- ---
358
-
359
- ## 📋 **Checklist de Migração**
360
-
361
- - [ ] Substituir `process.env.VAR` por `env.get('VAR')`
362
- - [ ] Usar `env.num()`, `env.bool()`, `env.array()` conforme tipo
363
- - [ ] Atualizar configuração do FluxStack
364
- - [ ] Testar em desenvolvimento
365
- - [ ] Testar build e produção
366
- - [ ] Verificar Docker/deploy
367
- - [ ] Documentar env vars específicas do projeto
368
-
369
- ---
370
-
371
- ## 🎯 **Benefícios**
372
-
373
- ✅ **Env vars dinâmicas** mesmo após Bun build
374
- ✅ **Deploy flexível** sem rebuild
375
- ✅ **Type-safe** com conversão automática
376
- ✅ **Validação** de env vars obrigatórias
377
- ✅ **Namespace** para organização
378
- ✅ **Compatibilidade** com Node.js e Bun
379
- ✅ **Performance** otimizada
380
- ✅ **Testing** friendly
@@ -1,283 +0,0 @@
1
- /**
2
- * Exemplos de como usar o sistema de Environment Variables dinâmico
3
- * Solução para o problema do Bun build fixar valores de process.env
4
- */
5
-
6
- // ========================================
7
- // 1. IMPORT DO SISTEMA DINÂMICO
8
- // ========================================
9
-
10
- import { env, runtimeEnv, envValidation } from '../core/utils/env-runtime'
11
- import { createRuntimeConfig, runtimeConfig, configHelpers } from '../core/config/runtime-config'
12
- import { dynamicEnvironmentProcessor } from '../core/config/env-dynamic'
13
-
14
- // ========================================
15
- // 2. USO BÁSICO - Substituir process.env
16
- // ========================================
17
-
18
- // ❌ ANTES (fixado pelo Bun build):
19
- // const port = process.env.PORT || 3000
20
- // const dbUrl = process.env.DATABASE_URL
21
-
22
- // ✅ DEPOIS (dinâmico em runtime):
23
- const port = env.num('PORT', 3000)
24
- const dbUrl = env.get('DATABASE_URL')
25
- const isDebug = env.bool('DEBUG', false)
26
- const corsOrigins = env.array('CORS_ORIGINS', ['*'])
27
-
28
- console.log('🚀 Server will start on port:', port) // Valor dinâmico!
29
-
30
- // ========================================
31
- // 3. CONFIGURAÇÃO DE SERVIDOR DINÂMICA
32
- // ========================================
33
-
34
- export function createDynamicServer() {
35
- // Configuração que funciona em produção sem rebuild
36
- const serverConfig = {
37
- port: env.num('PORT', 3000),
38
- host: env.get('HOST', 'localhost'),
39
-
40
- // Database dinâmico
41
- database: {
42
- url: env.get('DATABASE_URL'),
43
- maxConnections: env.num('DB_MAX_CONNECTIONS', 10),
44
- ssl: env.bool('DB_SSL', env.get('NODE_ENV') === 'production')
45
- },
46
-
47
- // CORS dinâmico
48
- cors: {
49
- origins: env.array('CORS_ORIGINS', ['*']),
50
- credentials: env.bool('CORS_CREDENTIALS', false)
51
- },
52
-
53
- // JWT dinâmico
54
- jwt: {
55
- secret: env.get('JWT_SECRET') || generateSecret(),
56
- expiresIn: env.get('JWT_EXPIRES_IN', '24h')
57
- },
58
-
59
- // Features dinâmicas
60
- features: {
61
- monitoring: env.bool('ENABLE_MONITORING', env.get('NODE_ENV') === 'production'),
62
- metrics: env.bool('ENABLE_METRICS', false),
63
- swagger: env.bool('ENABLE_SWAGGER', env.get('NODE_ENV') !== 'production')
64
- }
65
- }
66
-
67
- return serverConfig
68
- }
69
-
70
- // ========================================
71
- // 4. FLUXSTACK COM ENV DINÂMICO
72
- // ========================================
73
-
74
- import { FluxStackFramework } from '../core/framework/server'
75
-
76
- export function createFluxStackWithDynamicEnv() {
77
- // Usar configuração runtime dinâmica
78
- const config = createRuntimeConfig({
79
- // Overrides específicos
80
- server: {
81
- port: env.num('PORT', 3000),
82
- host: env.get('HOST', 'localhost'),
83
- }
84
- })
85
-
86
- const app = new FluxStackFramework(config)
87
-
88
- // Configurações que mudam em runtime
89
- if (env.bool('ENABLE_SWAGGER', true)) {
90
- // Swagger só se habilitado
91
- }
92
-
93
- if (env.bool('ENABLE_MONITORING', false)) {
94
- // Monitoring só se habilitado
95
- }
96
-
97
- return app
98
- }
99
-
100
- // ========================================
101
- // 5. DIFERENTES AMBIENTES
102
- // ========================================
103
-
104
- export function createEnvironmentSpecificConfig() {
105
- const environment = env.get('NODE_ENV', 'development')
106
-
107
- switch (environment) {
108
- case 'development':
109
- return runtimeConfig.development()
110
-
111
- case 'production':
112
- return runtimeConfig.production()
113
-
114
- case 'test':
115
- return runtimeConfig.test()
116
-
117
- default:
118
- return runtimeConfig.auto()
119
- }
120
- }
121
-
122
- // ========================================
123
- // 6. VALIDAÇÃO DE ENV VARS
124
- // ========================================
125
-
126
- export function validateEnvironment() {
127
- // Validar vars obrigatórias
128
- envValidation.require(['NODE_ENV'])
129
-
130
- // Se production, validar mais vars
131
- if (env.get('NODE_ENV') === 'production') {
132
- envValidation.require([
133
- 'DATABASE_URL',
134
- 'JWT_SECRET'
135
- ])
136
-
137
- // Validar formato
138
- envValidation.validate('DATABASE_URL',
139
- (url) => url.includes('://'),
140
- 'DATABASE_URL deve ser uma URL válida'
141
- )
142
- }
143
- }
144
-
145
- // ========================================
146
- // 7. CONFIGURAÇÃO POR NAMESPACE
147
- // ========================================
148
-
149
- import { createEnvNamespace } from '../core/utils/env-runtime'
150
-
151
- // Criar loaders especializados
152
- const dbEnv = createEnvNamespace('DATABASE_')
153
- const redisEnv = createEnvNamespace('REDIS_')
154
- const awsEnv = createEnvNamespace('AWS_')
155
-
156
- export function createDatabaseConfig() {
157
- return {
158
- url: dbEnv.get('URL'), // DATABASE_URL
159
- host: dbEnv.get('HOST'), // DATABASE_HOST
160
- port: dbEnv.getNumber('PORT'), // DATABASE_PORT
161
- ssl: dbEnv.getBoolean('SSL'), // DATABASE_SSL
162
- }
163
- }
164
-
165
- export function createRedisConfig() {
166
- return {
167
- url: redisEnv.get('URL'), // REDIS_URL
168
- host: redisEnv.get('HOST'), // REDIS_HOST
169
- port: redisEnv.getNumber('PORT'), // REDIS_PORT
170
- }
171
- }
172
-
173
- // ========================================
174
- // 8. CONFIGURAÇÃO HELPERS
175
- // ========================================
176
-
177
- export function getAppConfig() {
178
- return {
179
- // Server config dinâmico
180
- server: configHelpers.getServerConfig(),
181
-
182
- // Client config dinâmico
183
- client: configHelpers.getClientConfig(),
184
-
185
- // Database com validação
186
- database: configHelpers.getDatabaseUrl(),
187
-
188
- // CORS com defaults inteligentes
189
- cors: configHelpers.getCorsOrigins()
190
- }
191
- }
192
-
193
- // ========================================
194
- // 9. EXEMPLO COMPLETO DE USO
195
- // ========================================
196
-
197
- export async function startFluxStackServer() {
198
- console.log('🔧 Validating environment...')
199
- validateEnvironment()
200
-
201
- console.log('⚙️ Loading dynamic configuration...')
202
- const config = createEnvironmentSpecificConfig()
203
-
204
- console.log('🚀 Starting FluxStack with dynamic env...')
205
- const app = new FluxStackFramework(config)
206
-
207
- // Log das configurações atuais (valores dinâmicos!)
208
- console.log('📊 Configuration loaded:')
209
- console.log(` Environment: ${env.get('NODE_ENV')}`)
210
- console.log(` Port: ${env.num('PORT', 3000)}`)
211
- console.log(` Database: ${env.get('DATABASE_URL') ? '✅ Connected' : '❌ Not configured'}`)
212
- console.log(` Monitoring: ${env.bool('ENABLE_MONITORING') ? '✅ Enabled' : '❌ Disabled'}`)
213
-
214
- await app.listen()
215
-
216
- console.log('✅ Server started with dynamic environment variables!')
217
- }
218
-
219
- // ========================================
220
- // 10. MIGRANDO CÓDIGO EXISTENTE
221
- // ========================================
222
-
223
- // ❌ Código antigo que será fixado pelo Bun:
224
- export const oldConfig = {
225
- port: parseInt(process.env.PORT || '3000'),
226
- dbUrl: process.env.DATABASE_URL,
227
- debug: process.env.DEBUG === 'true'
228
- }
229
-
230
- // ✅ Código novo que funciona dinamicamente:
231
- export const newConfig = {
232
- port: env.num('PORT', 3000),
233
- dbUrl: env.get('DATABASE_URL'),
234
- debug: env.bool('DEBUG', false)
235
- }
236
-
237
- // ========================================
238
- // 11. TESTES COM ENV DINÂMICO
239
- // ========================================
240
-
241
- export function createTestConfig() {
242
- // Configuração para testes que não interfere com env vars reais
243
- return runtimeConfig.test()
244
- }
245
-
246
- // Helper para simular env vars em testes
247
- export function withTestEnv(envVars: Record<string, string>, fn: () => void) {
248
- const original = { ...runtimeEnv.all() }
249
-
250
- // Simular env vars
251
- Object.assign(process.env, envVars)
252
-
253
- try {
254
- fn()
255
- } finally {
256
- // Restaurar env original
257
- Object.keys(envVars).forEach(key => {
258
- if (original[key] !== undefined) {
259
- process.env[key] = original[key]
260
- } else {
261
- delete process.env[key]
262
- }
263
- })
264
- }
265
- }
266
-
267
- // Função helper para gerar secret se não existir
268
- function generateSecret(): string {
269
- console.warn('⚠️ JWT_SECRET not found, generating random secret for development')
270
- return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
271
- }
272
-
273
- // ========================================
274
- // 12. EXPORT DEFAULT
275
- // ========================================
276
-
277
- export default {
278
- createDynamicServer,
279
- createFluxStackWithDynamicEnv,
280
- validateEnvironment,
281
- startFluxStackServer,
282
- getAppConfig
283
- }