@buenojs/bueno 0.8.4 → 0.8.6

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 (234) hide show
  1. package/README.md +264 -17
  2. package/dist/cli/{index.js → bin.js} +413 -332
  3. package/dist/container/index.js +273 -0
  4. package/dist/context/index.js +219 -0
  5. package/dist/database/index.js +493 -0
  6. package/dist/frontend/index.js +7697 -0
  7. package/dist/graphql/index.js +2156 -0
  8. package/dist/health/index.js +364 -0
  9. package/dist/i18n/index.js +345 -0
  10. package/dist/index.js +9694 -5047
  11. package/dist/jobs/index.js +819 -0
  12. package/dist/lock/index.js +367 -0
  13. package/dist/logger/index.js +281 -0
  14. package/dist/metrics/index.js +289 -0
  15. package/dist/middleware/index.js +77 -0
  16. package/dist/migrations/index.js +571 -0
  17. package/dist/modules/index.js +3411 -0
  18. package/dist/notification/index.js +484 -0
  19. package/dist/observability/index.js +331 -0
  20. package/dist/openapi/index.js +795 -0
  21. package/dist/orm/index.js +1356 -0
  22. package/dist/router/index.js +886 -0
  23. package/dist/rpc/index.js +691 -0
  24. package/dist/schema/index.js +400 -0
  25. package/dist/telemetry/index.js +595 -0
  26. package/dist/template/index.js +640 -0
  27. package/dist/templates/index.js +640 -0
  28. package/dist/testing/index.js +1111 -0
  29. package/dist/types/index.js +60 -0
  30. package/llms.txt +231 -0
  31. package/package.json +125 -27
  32. package/src/cache/index.ts +2 -1
  33. package/src/cli/ARCHITECTURE.md +3 -3
  34. package/src/cli/bin.ts +2 -2
  35. package/src/cli/commands/build.ts +183 -165
  36. package/src/cli/commands/dev.ts +96 -89
  37. package/src/cli/commands/generate.ts +142 -111
  38. package/src/cli/commands/help.ts +20 -16
  39. package/src/cli/commands/index.ts +3 -6
  40. package/src/cli/commands/migration.ts +124 -105
  41. package/src/cli/commands/new.ts +294 -232
  42. package/src/cli/commands/start.ts +81 -79
  43. package/src/cli/core/args.ts +68 -50
  44. package/src/cli/core/console.ts +89 -95
  45. package/src/cli/core/index.ts +4 -4
  46. package/src/cli/core/prompt.ts +65 -62
  47. package/src/cli/core/spinner.ts +23 -20
  48. package/src/cli/index.ts +46 -38
  49. package/src/cli/templates/database/index.ts +37 -18
  50. package/src/cli/templates/database/mysql.ts +3 -3
  51. package/src/cli/templates/database/none.ts +2 -2
  52. package/src/cli/templates/database/postgresql.ts +3 -3
  53. package/src/cli/templates/database/sqlite.ts +3 -3
  54. package/src/cli/templates/deploy.ts +29 -26
  55. package/src/cli/templates/docker.ts +41 -30
  56. package/src/cli/templates/frontend/index.ts +33 -15
  57. package/src/cli/templates/frontend/none.ts +2 -2
  58. package/src/cli/templates/frontend/react.ts +18 -18
  59. package/src/cli/templates/frontend/solid.ts +15 -15
  60. package/src/cli/templates/frontend/svelte.ts +17 -17
  61. package/src/cli/templates/frontend/vue.ts +15 -15
  62. package/src/cli/templates/generators/index.ts +29 -29
  63. package/src/cli/templates/generators/types.ts +21 -21
  64. package/src/cli/templates/index.ts +6 -6
  65. package/src/cli/templates/project/api.ts +37 -36
  66. package/src/cli/templates/project/default.ts +25 -25
  67. package/src/cli/templates/project/fullstack.ts +28 -26
  68. package/src/cli/templates/project/index.ts +55 -16
  69. package/src/cli/templates/project/minimal.ts +17 -12
  70. package/src/cli/templates/project/types.ts +10 -5
  71. package/src/cli/templates/project/website.ts +15 -15
  72. package/src/cli/utils/fs.ts +55 -41
  73. package/src/cli/utils/index.ts +3 -3
  74. package/src/cli/utils/strings.ts +47 -33
  75. package/src/cli/utils/version.ts +14 -8
  76. package/src/config/env-validation.ts +100 -0
  77. package/src/config/env.ts +169 -41
  78. package/src/config/index.ts +28 -20
  79. package/src/config/loader.ts +25 -16
  80. package/src/config/merge.ts +21 -10
  81. package/src/config/types.ts +566 -25
  82. package/src/config/validation.ts +215 -7
  83. package/src/container/forward-ref.ts +22 -22
  84. package/src/container/index.ts +34 -12
  85. package/src/context/index.ts +11 -1
  86. package/src/database/index.ts +7 -190
  87. package/src/database/orm/builder.ts +457 -0
  88. package/src/database/orm/casts/index.ts +130 -0
  89. package/src/database/orm/casts/types.ts +25 -0
  90. package/src/database/orm/compiler.ts +304 -0
  91. package/src/database/orm/hooks/index.ts +114 -0
  92. package/src/database/orm/index.ts +61 -0
  93. package/src/database/orm/model-registry.ts +59 -0
  94. package/src/database/orm/model.ts +821 -0
  95. package/src/database/orm/relationships/base.ts +146 -0
  96. package/src/database/orm/relationships/belongs-to-many.ts +179 -0
  97. package/src/database/orm/relationships/belongs-to.ts +56 -0
  98. package/src/database/orm/relationships/has-many.ts +45 -0
  99. package/src/database/orm/relationships/has-one.ts +41 -0
  100. package/src/database/orm/relationships/index.ts +11 -0
  101. package/src/database/orm/scopes/index.ts +55 -0
  102. package/src/events/__tests__/event-system.test.ts +235 -0
  103. package/src/events/config.ts +238 -0
  104. package/src/events/example-usage.ts +185 -0
  105. package/src/events/index.ts +278 -0
  106. package/src/events/manager.ts +385 -0
  107. package/src/events/registry.ts +182 -0
  108. package/src/events/types.ts +124 -0
  109. package/src/frontend/api-routes.ts +65 -23
  110. package/src/frontend/bundler.ts +76 -34
  111. package/src/frontend/console-client.ts +2 -2
  112. package/src/frontend/console-stream.ts +94 -38
  113. package/src/frontend/dev-server.ts +94 -46
  114. package/src/frontend/file-router.ts +61 -19
  115. package/src/frontend/frameworks/index.ts +37 -10
  116. package/src/frontend/frameworks/react.ts +10 -8
  117. package/src/frontend/frameworks/solid.ts +11 -9
  118. package/src/frontend/frameworks/svelte.ts +15 -9
  119. package/src/frontend/frameworks/vue.ts +13 -11
  120. package/src/frontend/hmr-client.ts +12 -10
  121. package/src/frontend/hmr.ts +146 -103
  122. package/src/frontend/index.ts +14 -5
  123. package/src/frontend/islands.ts +41 -22
  124. package/src/frontend/isr.ts +59 -37
  125. package/src/frontend/layout.ts +36 -21
  126. package/src/frontend/ssr/react.ts +74 -27
  127. package/src/frontend/ssr/solid.ts +54 -20
  128. package/src/frontend/ssr/svelte.ts +48 -14
  129. package/src/frontend/ssr/vue.ts +50 -18
  130. package/src/frontend/ssr.ts +83 -39
  131. package/src/frontend/types.ts +91 -56
  132. package/src/graphql/built-in-engine.ts +598 -0
  133. package/src/graphql/context-builder.ts +110 -0
  134. package/src/graphql/decorators.ts +358 -0
  135. package/src/graphql/execution-pipeline.ts +227 -0
  136. package/src/graphql/graphql-module.ts +563 -0
  137. package/src/graphql/index.ts +101 -0
  138. package/src/graphql/metadata.ts +237 -0
  139. package/src/graphql/schema-builder.ts +319 -0
  140. package/src/graphql/subscription-handler.ts +283 -0
  141. package/src/graphql/types.ts +324 -0
  142. package/src/health/index.ts +21 -9
  143. package/src/i18n/engine.ts +305 -0
  144. package/src/i18n/index.ts +38 -0
  145. package/src/i18n/loader.ts +218 -0
  146. package/src/i18n/middleware.ts +164 -0
  147. package/src/i18n/negotiator.ts +162 -0
  148. package/src/i18n/types.ts +158 -0
  149. package/src/index.ts +182 -27
  150. package/src/jobs/drivers/memory.ts +315 -0
  151. package/src/jobs/drivers/redis.ts +459 -0
  152. package/src/jobs/index.ts +30 -0
  153. package/src/jobs/queue.ts +281 -0
  154. package/src/jobs/types.ts +295 -0
  155. package/src/jobs/worker.ts +380 -0
  156. package/src/logger/index.ts +1 -3
  157. package/src/logger/transports/index.ts +62 -22
  158. package/src/metrics/index.ts +25 -16
  159. package/src/migrations/index.ts +9 -0
  160. package/src/modules/filters.ts +13 -17
  161. package/src/modules/guards.ts +49 -26
  162. package/src/modules/index.ts +457 -299
  163. package/src/modules/interceptors.ts +58 -20
  164. package/src/modules/lazy.ts +11 -19
  165. package/src/modules/lifecycle.ts +15 -7
  166. package/src/modules/metadata.ts +15 -5
  167. package/src/modules/pipes.ts +94 -72
  168. package/src/notification/channels/base.ts +68 -0
  169. package/src/notification/channels/email.ts +105 -0
  170. package/src/notification/channels/push.ts +104 -0
  171. package/src/notification/channels/sms.ts +105 -0
  172. package/src/notification/channels/whatsapp.ts +104 -0
  173. package/src/notification/index.ts +48 -0
  174. package/src/notification/service.ts +354 -0
  175. package/src/notification/types.ts +344 -0
  176. package/src/observability/__tests__/observability.test.ts +483 -0
  177. package/src/observability/breadcrumbs.ts +114 -0
  178. package/src/observability/index.ts +136 -0
  179. package/src/observability/interceptor.ts +85 -0
  180. package/src/observability/service.ts +303 -0
  181. package/src/observability/trace.ts +37 -0
  182. package/src/observability/types.ts +196 -0
  183. package/src/openapi/__tests__/decorators.test.ts +335 -0
  184. package/src/openapi/__tests__/document-builder.test.ts +285 -0
  185. package/src/openapi/__tests__/route-scanner.test.ts +334 -0
  186. package/src/openapi/__tests__/schema-generator.test.ts +275 -0
  187. package/src/openapi/decorators.ts +328 -0
  188. package/src/openapi/document-builder.ts +274 -0
  189. package/src/openapi/index.ts +112 -0
  190. package/src/openapi/metadata.ts +112 -0
  191. package/src/openapi/route-scanner.ts +289 -0
  192. package/src/openapi/schema-generator.ts +256 -0
  193. package/src/openapi/swagger-module.ts +166 -0
  194. package/src/openapi/types.ts +398 -0
  195. package/src/orm/index.ts +10 -0
  196. package/src/rpc/index.ts +3 -1
  197. package/src/schema/index.ts +9 -0
  198. package/src/security/index.ts +15 -6
  199. package/src/ssg/index.ts +9 -8
  200. package/src/telemetry/index.ts +76 -22
  201. package/src/template/index.ts +7 -0
  202. package/src/templates/engine.ts +224 -0
  203. package/src/templates/index.ts +9 -0
  204. package/src/templates/loader.ts +331 -0
  205. package/src/templates/renderers/markdown.ts +212 -0
  206. package/src/templates/renderers/simple.ts +269 -0
  207. package/src/templates/types.ts +154 -0
  208. package/src/testing/index.ts +100 -27
  209. package/src/types/optional-deps.d.ts +347 -187
  210. package/src/validation/index.ts +92 -2
  211. package/src/validation/schemas.ts +536 -0
  212. package/tests/integration/cli.test.ts +19 -19
  213. package/tests/integration/fullstack.test.ts +4 -4
  214. package/tests/unit/cli.test.ts +1 -1
  215. package/tests/unit/database.test.ts +2 -72
  216. package/tests/unit/env-validation.test.ts +166 -0
  217. package/tests/unit/events.test.ts +910 -0
  218. package/tests/unit/graphql.test.ts +991 -0
  219. package/tests/unit/i18n.test.ts +455 -0
  220. package/tests/unit/jobs.test.ts +493 -0
  221. package/tests/unit/notification.test.ts +988 -0
  222. package/tests/unit/observability.test.ts +453 -0
  223. package/tests/unit/orm/builder.test.ts +323 -0
  224. package/tests/unit/orm/casts.test.ts +179 -0
  225. package/tests/unit/orm/compiler.test.ts +220 -0
  226. package/tests/unit/orm/eager-loading.test.ts +285 -0
  227. package/tests/unit/orm/hooks.test.ts +191 -0
  228. package/tests/unit/orm/model.test.ts +373 -0
  229. package/tests/unit/orm/relationships.test.ts +303 -0
  230. package/tests/unit/orm/scopes.test.ts +74 -0
  231. package/tests/unit/templates-simple.test.ts +53 -0
  232. package/tests/unit/templates.test.ts +454 -0
  233. package/tests/unit/validation.test.ts +18 -24
  234. package/tsconfig.json +11 -3
@@ -2,13 +2,13 @@
2
2
  * Svelte Frontend Template
3
3
  */
4
4
 
5
- import type { FrontendTemplateResult } from '../project/types';
5
+ import type { FrontendTemplateResult } from "../project/types";
6
6
 
7
7
  export function svelteTemplate(): FrontendTemplateResult {
8
8
  return {
9
9
  files: [
10
10
  {
11
- path: 'client/index.html',
11
+ path: "client/index.html",
12
12
  content: `<!DOCTYPE html>
13
13
  <html lang="en">
14
14
  <head>
@@ -24,7 +24,7 @@ export function svelteTemplate(): FrontendTemplateResult {
24
24
  `,
25
25
  },
26
26
  {
27
- path: 'client/src/main.ts',
27
+ path: "client/src/main.ts",
28
28
  content: `import App from './App.svelte';
29
29
  import './styles/globals.css';
30
30
 
@@ -36,7 +36,7 @@ export default app;
36
36
  `,
37
37
  },
38
38
  {
39
- path: 'client/src/App.svelte',
39
+ path: "client/src/App.svelte",
40
40
  content: `<script lang="ts">
41
41
  let count = 0;
42
42
  </script>
@@ -85,7 +85,7 @@ export default app;
85
85
  `,
86
86
  },
87
87
  {
88
- path: 'client/src/styles/globals.css',
88
+ path: "client/src/styles/globals.css",
89
89
  content: `@tailwind base;
90
90
  @tailwind components;
91
91
  @tailwind utilities;
@@ -109,23 +109,23 @@ body {
109
109
  },
110
110
  ],
111
111
  directories: [
112
- 'client/src/components',
113
- 'client/src/styles',
114
- 'client/public',
112
+ "client/src/components",
113
+ "client/src/styles",
114
+ "client/public",
115
115
  ],
116
116
  dependencies: {
117
- svelte: '^4.2.0',
117
+ svelte: "^4.2.0",
118
118
  },
119
119
  devDependencies: {
120
- '@sveltejs/vite-plugin-svelte': '^3.0.0',
121
- svelte: '^4.2.0',
122
- tailwindcss: '^3.4.0',
123
- postcss: '^8.4.0',
124
- autoprefixer: '^10.4.0',
120
+ "@sveltejs/vite-plugin-svelte": "^3.0.0",
121
+ svelte: "^4.2.0",
122
+ tailwindcss: "^3.4.0",
123
+ postcss: "^8.4.0",
124
+ autoprefixer: "^10.4.0",
125
125
  },
126
126
  scripts: {
127
- 'dev:client': 'bun run --watch client/index.html',
128
- 'build:client': 'bun build ./client/src/main.ts --outdir ./dist/client',
127
+ "dev:client": "bun run --watch client/index.html",
128
+ "build:client": "bun build ./client/src/main.ts --outdir ./dist/client",
129
129
  },
130
130
  };
131
- }
131
+ }
@@ -2,13 +2,13 @@
2
2
  * Vue Frontend Template
3
3
  */
4
4
 
5
- import type { FrontendTemplateResult } from '../project/types';
5
+ import type { FrontendTemplateResult } from "../project/types";
6
6
 
7
7
  export function vueTemplate(): FrontendTemplateResult {
8
8
  return {
9
9
  files: [
10
10
  {
11
- path: 'client/index.html',
11
+ path: "client/index.html",
12
12
  content: `<!DOCTYPE html>
13
13
  <html lang="en">
14
14
  <head>
@@ -24,7 +24,7 @@ export function vueTemplate(): FrontendTemplateResult {
24
24
  `,
25
25
  },
26
26
  {
27
- path: 'client/src/main.ts',
27
+ path: "client/src/main.ts",
28
28
  content: `import { createApp } from 'vue';
29
29
  import App from './App.vue';
30
30
  import './styles/globals.css';
@@ -33,7 +33,7 @@ createApp(App).mount('#app');
33
33
  `,
34
34
  },
35
35
  {
36
- path: 'client/src/App.vue',
36
+ path: "client/src/App.vue",
37
37
  content: `<script setup lang="ts">
38
38
  import { ref } from 'vue';
39
39
 
@@ -86,7 +86,7 @@ const count = ref(0);
86
86
  `,
87
87
  },
88
88
  {
89
- path: 'client/src/styles/globals.css',
89
+ path: "client/src/styles/globals.css",
90
90
  content: `@tailwind base;
91
91
  @tailwind components;
92
92
  @tailwind utilities;
@@ -110,21 +110,21 @@ body {
110
110
  },
111
111
  ],
112
112
  directories: [
113
- 'client/src/components',
114
- 'client/src/styles',
115
- 'client/public',
113
+ "client/src/components",
114
+ "client/src/styles",
115
+ "client/public",
116
116
  ],
117
117
  dependencies: {
118
- vue: '^3.4.0',
118
+ vue: "^3.4.0",
119
119
  },
120
120
  devDependencies: {
121
- tailwindcss: '^3.4.0',
122
- postcss: '^8.4.0',
123
- autoprefixer: '^10.4.0',
121
+ tailwindcss: "^3.4.0",
122
+ postcss: "^8.4.0",
123
+ autoprefixer: "^10.4.0",
124
124
  },
125
125
  scripts: {
126
- 'dev:client': 'bun run --watch client/index.html',
127
- 'build:client': 'bun build ./client/src/main.ts --outdir ./dist/client',
126
+ "dev:client": "bun run --watch client/index.html",
127
+ "build:client": "bun build ./client/src/main.ts --outdir ./dist/client",
128
128
  },
129
129
  };
130
- }
130
+ }
@@ -9,11 +9,11 @@ export type {
9
9
  GeneratorType,
10
10
  GeneratorConfig,
11
11
  GeneratorResult,
12
- } from './types';
12
+ } from "./types";
13
13
 
14
- export { GENERATOR_ALIASES } from './types';
14
+ export { GENERATOR_ALIASES } from "./types";
15
15
 
16
- import type { GeneratorType, GeneratorConfig, GeneratorResult } from './types';
16
+ import type { GeneratorConfig, GeneratorResult, GeneratorType } from "./types";
17
17
 
18
18
  /**
19
19
  * Generator template function type
@@ -55,25 +55,25 @@ export function getGeneratorTypes(): GeneratorType[] {
55
55
  */
56
56
  export function getDefaultDirectory(type: GeneratorType): string {
57
57
  switch (type) {
58
- case 'controller':
59
- case 'service':
60
- case 'module':
61
- case 'dto':
62
- return 'modules';
63
- case 'guard':
64
- return 'common/guards';
65
- case 'interceptor':
66
- return 'common/interceptors';
67
- case 'pipe':
68
- return 'common/pipes';
69
- case 'filter':
70
- return 'common/filters';
71
- case 'middleware':
72
- return 'common/middleware';
73
- case 'migration':
74
- return 'database/migrations';
58
+ case "controller":
59
+ case "service":
60
+ case "module":
61
+ case "dto":
62
+ return "modules";
63
+ case "guard":
64
+ return "common/guards";
65
+ case "interceptor":
66
+ return "common/interceptors";
67
+ case "pipe":
68
+ return "common/pipes";
69
+ case "filter":
70
+ return "common/filters";
71
+ case "middleware":
72
+ return "common/middleware";
73
+ case "migration":
74
+ return "database/migrations";
75
75
  default:
76
- return '';
76
+ return "";
77
77
  }
78
78
  }
79
79
 
@@ -81,7 +81,7 @@ export function getDefaultDirectory(type: GeneratorType): string {
81
81
  * Get file extension for generator type
82
82
  */
83
83
  export function getFileExtension(type: GeneratorType): string {
84
- return type === 'dto' ? '.dto.ts' : '.ts';
84
+ return type === "dto" ? ".dto.ts" : ".ts";
85
85
  }
86
86
 
87
87
  // ============= Template Functions =============
@@ -305,7 +305,7 @@ export const {{camelCase name}}Middleware: Middleware = async (
305
305
 
306
306
  function getMigrationTemplate(config: GeneratorConfig): string {
307
307
  const migrationId = generateMigrationId();
308
- return `import { createMigration, type MigrationRunner } from '@buenojs/bueno';
308
+ return `import { createMigration, type MigrationRunner } from '@buenojs/bueno/migrations';
309
309
 
310
310
  export default createMigration('${migrationId}', '{{migrationName}}')
311
311
  .up(async (db: MigrationRunner) => {
@@ -330,10 +330,10 @@ export default createMigration('${migrationId}', '{{migrationName}}')
330
330
  function generateMigrationId(): string {
331
331
  const now = new Date();
332
332
  const year = now.getFullYear();
333
- const month = String(now.getMonth() + 1).padStart(2, '0');
334
- const day = String(now.getDate()).padStart(2, '0');
335
- const hour = String(now.getHours()).padStart(2, '0');
336
- const minute = String(now.getMinutes()).padStart(2, '0');
337
- const second = String(now.getSeconds()).padStart(2, '0');
333
+ const month = String(now.getMonth() + 1).padStart(2, "0");
334
+ const day = String(now.getDate()).padStart(2, "0");
335
+ const hour = String(now.getHours()).padStart(2, "0");
336
+ const minute = String(now.getMinutes()).padStart(2, "0");
337
+ const second = String(now.getSeconds()).padStart(2, "0");
338
338
  return `${year}${month}${day}${hour}${minute}${second}`;
339
- }
339
+ }
@@ -8,31 +8,31 @@
8
8
  * Generator types available
9
9
  */
10
10
  export type GeneratorType =
11
- | 'controller'
12
- | 'service'
13
- | 'module'
14
- | 'guard'
15
- | 'interceptor'
16
- | 'pipe'
17
- | 'filter'
18
- | 'dto'
19
- | 'middleware'
20
- | 'migration';
11
+ | "controller"
12
+ | "service"
13
+ | "module"
14
+ | "guard"
15
+ | "interceptor"
16
+ | "pipe"
17
+ | "filter"
18
+ | "dto"
19
+ | "middleware"
20
+ | "migration";
21
21
 
22
22
  /**
23
23
  * Generator aliases
24
24
  */
25
25
  export const GENERATOR_ALIASES: Record<string, GeneratorType> = {
26
- c: 'controller',
27
- s: 'service',
28
- m: 'module',
29
- gu: 'guard',
30
- i: 'interceptor',
31
- p: 'pipe',
32
- f: 'filter',
33
- d: 'dto',
34
- mw: 'middleware',
35
- mi: 'migration',
26
+ c: "controller",
27
+ s: "service",
28
+ m: "module",
29
+ gu: "guard",
30
+ i: "interceptor",
31
+ p: "pipe",
32
+ f: "filter",
33
+ d: "dto",
34
+ mw: "middleware",
35
+ mi: "migration",
36
36
  };
37
37
 
38
38
  /**
@@ -53,4 +53,4 @@ export interface GeneratorConfig {
53
53
  export interface GeneratorResult {
54
54
  filePath: string;
55
55
  content: string;
56
- }
56
+ }
@@ -10,7 +10,7 @@ export {
10
10
  getDockerignoreTemplate,
11
11
  getDockerComposeTemplate,
12
12
  getDockerEnvTemplate,
13
- } from './docker';
13
+ } from "./docker";
14
14
 
15
15
  // Cloud platform deployment templates
16
16
  export {
@@ -21,7 +21,7 @@ export {
21
21
  getDeployTemplate,
22
22
  getDeployFilename,
23
23
  getDeployPlatformName,
24
- } from './deploy';
24
+ } from "./deploy";
25
25
 
26
26
  // Project templates
27
27
  export {
@@ -31,19 +31,19 @@ export {
31
31
  type DatabaseDriver,
32
32
  getProjectTemplate,
33
33
  getTemplateOptions,
34
- } from './project';
34
+ } from "./project";
35
35
 
36
36
  // Database templates
37
37
  export {
38
38
  getDatabaseTemplate,
39
39
  getDatabaseOptions,
40
- } from './database';
40
+ } from "./database";
41
41
 
42
42
  // Frontend templates
43
43
  export {
44
44
  getFrontendTemplate,
45
45
  getFrontendOptions,
46
- } from './frontend';
46
+ } from "./frontend";
47
47
 
48
48
  // Generator templates
49
49
  export {
@@ -54,4 +54,4 @@ export {
54
54
  getGeneratorTypes,
55
55
  getDefaultDirectory,
56
56
  getFileExtension,
57
- } from './generators';
57
+ } from "./generators";
@@ -2,79 +2,80 @@
2
2
  * API Project Template
3
3
  */
4
4
 
5
- import type { ProjectConfig, ProjectTemplateResult } from './types';
6
- import { getBuenoDependency } from '../../utils/version';
5
+ import { getBuenoDependency } from "../../utils/version";
6
+ import type { ProjectConfig, ProjectTemplateResult } from "./types";
7
7
 
8
8
  export function apiTemplate(config: ProjectConfig): ProjectTemplateResult {
9
9
  return {
10
10
  files: [
11
11
  {
12
- path: 'server/main.ts',
12
+ path: "server/main.ts",
13
13
  content: `import { createApp, Module, Controller, Get, Post, Injectable } from '@buenojs/bueno';
14
14
  import type { Context } from '@buenojs/bueno';
15
15
 
16
16
  // Services
17
17
  @Injectable()
18
18
  export class AppService {
19
- findAll() {
20
- return { message: 'Welcome to Bueno API!', items: [] };
21
- }
19
+ findAll() {
20
+ return { message: 'Welcome to Bueno API!', items: [] };
21
+ }
22
22
  }
23
23
 
24
24
  // Controllers
25
- @Controller()
25
+ @Controller('/api')
26
26
  export class AppController {
27
- constructor(private readonly appService: AppService) {}
27
+ constructor(private readonly appService: AppService) {}
28
28
 
29
- @Get()
30
- hello() {
31
- return { message: 'Welcome to Bueno API!', version: '1.0.0' };
32
- }
29
+ @Get()
30
+ hello() {
31
+ return Response.json({ message: 'Welcome to Bueno API!', version: '1.0.0' });
32
+ }
33
33
 
34
- @Get('health')
35
- health(ctx: Context) {
36
- return { status: 'ok', timestamp: new Date().toISOString() };
37
- }
34
+ @Get('health')
35
+ health(ctx: Context) {
36
+ return Response.json({ status: 'ok', timestamp: new Date().toISOString() });
37
+ }
38
38
  }
39
39
 
40
40
  // Module
41
41
  @Module({
42
- controllers: [AppController],
43
- providers: [AppService],
42
+ controllers: [AppController],
43
+ providers: [AppService],
44
44
  })
45
45
  export class AppModule {}
46
46
 
47
47
  // Bootstrap
48
48
  const app = createApp(AppModule);
49
49
  await app.listen(3000);
50
+ console.log('🚀 API server running at http://localhost:3000/api');
50
51
  `,
51
52
  },
52
53
  ],
53
54
  directories: [
54
- 'server/modules/app',
55
- 'server/common/middleware',
56
- 'server/common/guards',
57
- 'server/common/interceptors',
58
- 'server/common/pipes',
59
- 'server/common/filters',
60
- 'server/database/migrations',
61
- 'server/config',
62
- 'tests/unit',
63
- 'tests/integration',
55
+ "server/modules/app",
56
+ "server/common/middleware",
57
+ "server/common/guards",
58
+ "server/common/interceptors",
59
+ "server/common/pipes",
60
+ "server/common/filters",
61
+ "server/database/migrations",
62
+ "server/config",
63
+ "tests/unit",
64
+ "tests/integration",
64
65
  ],
65
66
  dependencies: {
66
67
  ...getBuenoDependency(),
67
- zod: '^3.24.0',
68
+ zod: "^3.24.0",
68
69
  },
69
70
  devDependencies: {
70
- '@types/bun': 'latest',
71
- typescript: '^5.3.0',
71
+ "@types/bun": "latest",
72
+ typescript: "^5.3.0",
72
73
  },
73
74
  scripts: {
74
- dev: 'bun run --watch server/main.ts',
75
- build: 'bun build ./server/main.ts --outdir ./dist --target bun',
76
- start: 'bun run dist/main.js',
77
- test: 'bun test',
75
+ dev: "bun run --watch server/main.ts",
76
+ build: "bun build ./server/main.ts --outdir ./dist --target bun",
77
+ start: "bun run dist/main.js",
78
+ test: "bun test",
78
79
  },
79
80
  };
80
- }
81
+ }
@@ -2,12 +2,12 @@
2
2
  * Default Project Template
3
3
  */
4
4
 
5
- import type { ProjectConfig, ProjectTemplateResult } from './types';
6
- import { reactTemplate } from '../frontend/react';
7
- import { vueTemplate } from '../frontend/vue';
8
- import { svelteTemplate } from '../frontend/svelte';
9
- import { solidTemplate } from '../frontend/solid';
10
- import { noneTemplate } from '../frontend/none';
5
+ import { noneTemplate } from "../frontend/none";
6
+ import { reactTemplate } from "../frontend/react";
7
+ import { solidTemplate } from "../frontend/solid";
8
+ import { svelteTemplate } from "../frontend/svelte";
9
+ import { vueTemplate } from "../frontend/vue";
10
+ import type { ProjectConfig, ProjectTemplateResult } from "./types";
11
11
 
12
12
  export function defaultTemplate(config: ProjectConfig): ProjectTemplateResult {
13
13
  // Get frontend template based on framework
@@ -19,14 +19,14 @@ export function defaultTemplate(config: ProjectConfig): ProjectTemplateResult {
19
19
  none: noneTemplate,
20
20
  };
21
21
 
22
- const frontendTemplate = frontendTemplates[config.framework]
23
- ? frontendTemplates[config.framework]()
22
+ const frontendTemplate = frontendTemplates[config.framework]
23
+ ? frontendTemplates[config.framework]()
24
24
  : reactTemplate();
25
25
 
26
26
  return {
27
27
  files: [
28
28
  {
29
- path: 'server/main.ts',
29
+ path: "server/main.ts",
30
30
  content: `import { createApp, Module, Controller, Get, Injectable } from '@buenojs/bueno';
31
31
  import type { Context } from '@buenojs/bueno';
32
32
 
@@ -106,21 +106,21 @@ await app.listen(3000);
106
106
  ...frontendTemplate.files,
107
107
  ],
108
108
  directories: [
109
- 'server/modules/app',
110
- 'server/common/middleware',
111
- 'server/common/guards',
112
- 'server/common/interceptors',
113
- 'server/common/pipes',
114
- 'server/common/filters',
115
- 'server/database/migrations',
116
- 'server/config',
117
- 'tests/unit',
118
- 'tests/integration',
109
+ "server/modules/app",
110
+ "server/common/middleware",
111
+ "server/common/guards",
112
+ "server/common/interceptors",
113
+ "server/common/pipes",
114
+ "server/common/filters",
115
+ "server/database/migrations",
116
+ "server/config",
117
+ "tests/unit",
118
+ "tests/integration",
119
119
  // Include frontend directories
120
120
  ...frontendTemplate.directories,
121
121
  ],
122
122
  dependencies: {
123
- zod: '^3.24.0',
123
+ zod: "^3.24.0",
124
124
  // Include frontend dependencies
125
125
  ...frontendTemplate.dependencies,
126
126
  },
@@ -129,12 +129,12 @@ await app.listen(3000);
129
129
  ...frontendTemplate.devDependencies,
130
130
  },
131
131
  scripts: {
132
- dev: 'bun run --watch server/main.ts',
133
- build: 'bun build ./server/main.ts --outdir ./dist --target bun',
134
- start: 'bun run dist/main.js',
135
- test: 'bun test',
132
+ dev: "bun run --watch server/main.ts",
133
+ build: "bun build ./server/main.ts --outdir ./dist --target bun",
134
+ start: "bun run dist/main.js",
135
+ test: "bun test",
136
136
  // Include frontend scripts
137
137
  ...frontendTemplate.scripts,
138
138
  },
139
139
  };
140
- }
140
+ }
@@ -2,14 +2,16 @@
2
2
  * Fullstack Project Template
3
3
  */
4
4
 
5
- import type { ProjectConfig, ProjectTemplateResult } from './types';
6
- import { reactTemplate } from '../frontend/react';
7
- import { vueTemplate } from '../frontend/vue';
8
- import { svelteTemplate } from '../frontend/svelte';
9
- import { solidTemplate } from '../frontend/solid';
10
- import { noneTemplate } from '../frontend/none';
5
+ import { noneTemplate } from "../frontend/none";
6
+ import { reactTemplate } from "../frontend/react";
7
+ import { solidTemplate } from "../frontend/solid";
8
+ import { svelteTemplate } from "../frontend/svelte";
9
+ import { vueTemplate } from "../frontend/vue";
10
+ import type { ProjectConfig, ProjectTemplateResult } from "./types";
11
11
 
12
- export function fullstackTemplate(config: ProjectConfig): ProjectTemplateResult {
12
+ export function fullstackTemplate(
13
+ config: ProjectConfig,
14
+ ): ProjectTemplateResult {
13
15
  // Get frontend template based on framework
14
16
  const frontendTemplates: Record<string, () => ProjectTemplateResult> = {
15
17
  react: reactTemplate,
@@ -19,14 +21,14 @@ export function fullstackTemplate(config: ProjectConfig): ProjectTemplateResult
19
21
  none: noneTemplate,
20
22
  };
21
23
 
22
- const frontendTemplate = frontendTemplates[config.framework]
23
- ? frontendTemplates[config.framework]()
24
+ const frontendTemplate = frontendTemplates[config.framework]
25
+ ? frontendTemplates[config.framework]()
24
26
  : reactTemplate();
25
27
 
26
28
  return {
27
29
  files: [
28
30
  {
29
- path: 'server/main.ts',
31
+ path: "server/main.ts",
30
32
  content: `import { createApp, Module, Controller, Get, Post, Injectable } from '@buenojs/bueno';
31
33
  import type { Context } from '@buenojs/bueno';
32
34
 
@@ -75,21 +77,21 @@ console.log('🚀 Server running at http://localhost:3000');
75
77
  ...frontendTemplate.files,
76
78
  ],
77
79
  directories: [
78
- 'server/modules/app',
79
- 'server/common/middleware',
80
- 'server/common/guards',
81
- 'server/common/interceptors',
82
- 'server/common/pipes',
83
- 'server/common/filters',
84
- 'server/database/migrations',
85
- 'server/config',
86
- 'tests/unit',
87
- 'tests/integration',
80
+ "server/modules/app",
81
+ "server/common/middleware",
82
+ "server/common/guards",
83
+ "server/common/interceptors",
84
+ "server/common/pipes",
85
+ "server/common/filters",
86
+ "server/database/migrations",
87
+ "server/config",
88
+ "tests/unit",
89
+ "tests/integration",
88
90
  // Include frontend directories
89
91
  ...frontendTemplate.directories,
90
92
  ],
91
93
  dependencies: {
92
- zod: '^3.24.0',
94
+ zod: "^3.24.0",
93
95
  // Include frontend dependencies
94
96
  ...frontendTemplate.dependencies,
95
97
  },
@@ -98,12 +100,12 @@ console.log('🚀 Server running at http://localhost:3000');
98
100
  ...frontendTemplate.devDependencies,
99
101
  },
100
102
  scripts: {
101
- dev: 'bun run --watch server/main.ts',
102
- build: 'bun build ./server/main.ts --outdir ./dist --target bun',
103
- start: 'bun run dist/main.js',
104
- test: 'bun test',
103
+ dev: "bun run --watch server/main.ts",
104
+ build: "bun build ./server/main.ts --outdir ./dist --target bun",
105
+ start: "bun run dist/main.js",
106
+ test: "bun test",
105
107
  // Include frontend scripts
106
108
  ...frontendTemplate.scripts,
107
109
  },
108
110
  };
109
- }
111
+ }