@forinda/kickjs-cli 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/cli.d.ts +2 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/dist/cli.js +1195 -2392
  4. package/dist/commands/add.d.ts +5 -0
  5. package/dist/commands/add.d.ts.map +1 -0
  6. package/dist/commands/custom.d.ts +56 -0
  7. package/dist/commands/custom.d.ts.map +1 -0
  8. package/dist/commands/generate.d.ts +3 -0
  9. package/dist/commands/generate.d.ts.map +1 -0
  10. package/dist/commands/info.d.ts +3 -0
  11. package/dist/commands/info.d.ts.map +1 -0
  12. package/dist/commands/init.d.ts +3 -0
  13. package/dist/commands/init.d.ts.map +1 -0
  14. package/dist/commands/inspect.d.ts +3 -0
  15. package/dist/commands/inspect.d.ts.map +1 -0
  16. package/dist/commands/remove.d.ts +3 -0
  17. package/dist/commands/remove.d.ts.map +1 -0
  18. package/dist/commands/run.d.ts +3 -0
  19. package/dist/commands/run.d.ts.map +1 -0
  20. package/dist/commands/tinker.d.ts +3 -0
  21. package/dist/commands/tinker.d.ts.map +1 -0
  22. package/dist/config-11ag0rJc.js +3097 -0
  23. package/dist/config.d.ts +131 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/generators/adapter.d.ts +7 -0
  26. package/dist/generators/adapter.d.ts.map +1 -0
  27. package/dist/generators/config.d.ts +9 -0
  28. package/dist/generators/config.d.ts.map +1 -0
  29. package/dist/generators/controller.d.ts +11 -0
  30. package/dist/generators/controller.d.ts.map +1 -0
  31. package/dist/generators/dto.d.ts +11 -0
  32. package/dist/generators/dto.d.ts.map +1 -0
  33. package/dist/generators/guard.d.ts +11 -0
  34. package/dist/generators/guard.d.ts.map +1 -0
  35. package/dist/generators/job.d.ts +8 -0
  36. package/dist/generators/job.d.ts.map +1 -0
  37. package/dist/generators/middleware.d.ts +11 -0
  38. package/dist/generators/middleware.d.ts.map +1 -0
  39. package/dist/generators/module.d.ts +33 -0
  40. package/dist/generators/module.d.ts.map +1 -0
  41. package/dist/generators/patterns/cqrs.d.ts +3 -0
  42. package/dist/generators/patterns/cqrs.d.ts.map +1 -0
  43. package/dist/generators/patterns/ddd.d.ts +3 -0
  44. package/dist/generators/patterns/ddd.d.ts.map +1 -0
  45. package/dist/generators/patterns/index.d.ts +6 -0
  46. package/dist/generators/patterns/index.d.ts.map +1 -0
  47. package/dist/generators/patterns/minimal.d.ts +3 -0
  48. package/dist/generators/patterns/minimal.d.ts.map +1 -0
  49. package/dist/generators/patterns/rest.d.ts +3 -0
  50. package/dist/generators/patterns/rest.d.ts.map +1 -0
  51. package/dist/generators/patterns/types.d.ts +15 -0
  52. package/dist/generators/patterns/types.d.ts.map +1 -0
  53. package/dist/generators/project.d.ts +14 -0
  54. package/dist/generators/project.d.ts.map +1 -0
  55. package/dist/generators/remove-module.d.ts +12 -0
  56. package/dist/generators/remove-module.d.ts.map +1 -0
  57. package/dist/generators/resolver.d.ts +7 -0
  58. package/dist/generators/resolver.d.ts.map +1 -0
  59. package/dist/generators/scaffold.d.ts +20 -0
  60. package/dist/generators/scaffold.d.ts.map +1 -0
  61. package/dist/generators/service.d.ts +11 -0
  62. package/dist/generators/service.d.ts.map +1 -0
  63. package/dist/generators/templates/constants.d.ts +3 -0
  64. package/dist/generators/templates/constants.d.ts.map +1 -0
  65. package/dist/generators/templates/controller.d.ts +6 -0
  66. package/dist/generators/templates/controller.d.ts.map +1 -0
  67. package/dist/generators/templates/cqrs.d.ts +23 -0
  68. package/dist/generators/templates/cqrs.d.ts.map +1 -0
  69. package/dist/generators/templates/domain.d.ts +5 -0
  70. package/dist/generators/templates/domain.d.ts.map +1 -0
  71. package/dist/generators/templates/drizzle/index.d.ts +4 -0
  72. package/dist/generators/templates/drizzle/index.d.ts.map +1 -0
  73. package/dist/generators/templates/dtos.d.ts +5 -0
  74. package/dist/generators/templates/dtos.d.ts.map +1 -0
  75. package/dist/generators/templates/index.d.ts +14 -0
  76. package/dist/generators/templates/index.d.ts.map +1 -0
  77. package/dist/generators/templates/module-index.d.ts +13 -0
  78. package/dist/generators/templates/module-index.d.ts.map +1 -0
  79. package/dist/generators/templates/prisma/index.d.ts +3 -0
  80. package/dist/generators/templates/prisma/index.d.ts.map +1 -0
  81. package/dist/generators/templates/project-app.d.ts +9 -0
  82. package/dist/generators/templates/project-app.d.ts.map +1 -0
  83. package/dist/generators/templates/project-config.d.ts +23 -0
  84. package/dist/generators/templates/project-config.d.ts.map +1 -0
  85. package/dist/generators/templates/project-docs.d.ts +9 -0
  86. package/dist/generators/templates/project-docs.d.ts.map +1 -0
  87. package/dist/generators/templates/repository.d.ts +5 -0
  88. package/dist/generators/templates/repository.d.ts.map +1 -0
  89. package/dist/generators/templates/rest-service.d.ts +6 -0
  90. package/dist/generators/templates/rest-service.d.ts.map +1 -0
  91. package/dist/generators/templates/tests.d.ts +4 -0
  92. package/dist/generators/templates/tests.d.ts.map +1 -0
  93. package/dist/generators/templates/types.d.ts +20 -0
  94. package/dist/generators/templates/types.d.ts.map +1 -0
  95. package/dist/generators/templates/use-cases.d.ts +6 -0
  96. package/dist/generators/templates/use-cases.d.ts.map +1 -0
  97. package/dist/generators/test.d.ts +9 -0
  98. package/dist/generators/test.d.ts.map +1 -0
  99. package/dist/index.d.ts +12 -234
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +17 -2184
  102. package/dist/utils/fs.d.ts +11 -0
  103. package/dist/utils/fs.d.ts.map +1 -0
  104. package/dist/utils/naming.d.ts +18 -0
  105. package/dist/utils/naming.d.ts.map +1 -0
  106. package/dist/utils/resolve-out-dir.d.ts +25 -0
  107. package/dist/utils/resolve-out-dir.d.ts.map +1 -0
  108. package/dist/utils/shell.d.ts +3 -0
  109. package/dist/utils/shell.d.ts.map +1 -0
  110. package/package.json +6 -5
package/dist/index.js CHANGED
@@ -1,2184 +1,17 @@
1
- var Ue=Object.defineProperty;var s=(r,e)=>Ue(r,"name",{value:e,configurable:!0});import{join as ce}from"path";import{createInterface as Le}from"readline";import{writeFile as Me,mkdir as qe,access as ze,readFile as Rt}from"fs/promises";import{dirname as _e}from"path";var Fe=!1;async function l(r,e){Fe||(await qe(_e(r),{recursive:!0}),await Me(r,e,"utf-8"))}s(l,"writeFileSafe");async function F(r){try{return await ze(r),!0}catch{return!1}}s(F,"fileExists");function f(r){return r.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():"").replace(/^(.)/,e=>e.toUpperCase())}s(f,"toPascalCase");function w(r){let e=f(r);return e.charAt(0).toLowerCase()+e.slice(1)}s(w,"toCamelCase");function u(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}s(u,"toKebabCase");function E(r){return r.endsWith("s")?r:r.endsWith("x")||r.endsWith("z")||r.endsWith("sh")||r.endsWith("ch")?r+"es":r.endsWith("y")&&!/[aeiou]y$/.test(r)?r.slice(0,-1)+"ies":r+"s"}s(E,"pluralize");function le(r){return r.endsWith("s")?r:r.endsWith("x")||r.endsWith("z")||r.endsWith("sh")||r.endsWith("ch")?r+"es":r.endsWith("y")&&!/[aeiou]y$/i.test(r)?r.slice(0,-1)+"ies":r+"s"}s(le,"pluralizePascal");import{readFile as Ne,writeFile as We}from"fs/promises";var Ge={inmemory:"in-memory",drizzle:"Drizzle",prisma:"Prisma"};function ue(r){return r.charAt(0).toUpperCase()+r.slice(1).replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}s(ue,"toPascalRepoType");function Qe(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(Qe,"toKebabRepoType");function me(r){return Ge[r]??ue(r)}s(me,"repoLabel");function fe(r,e,t){let o={inmemory:`InMemory${r}Repository`,drizzle:`Drizzle${r}Repository`,prisma:`Prisma${r}Repository`},i={inmemory:`in-memory-${e}`,drizzle:`drizzle-${e}`,prisma:`prisma-${e}`};return{repoClass:o[t]??`${ue(t)}${r}Repository`,repoFile:i[t]??`${Qe(t)}-${e}`}}s(fe,"repoMaps");function G(r){let{pascal:e,kebab:t,plural:o="",repo:i}=r,{repoClass:a,repoFile:c}=fe(e,t,i);return`/**
2
- * ${e} Module
3
- *
4
- * Self-contained feature module following Domain-Driven Design (DDD).
5
- * Registers dependencies in the DI container and declares HTTP routes.
6
- *
7
- * Structure:
8
- * presentation/ \u2014 HTTP controllers (entry points)
9
- * application/ \u2014 Use cases (orchestration) and DTOs (validation)
10
- * domain/ \u2014 Entities, value objects, repository interfaces, domain services
11
- * infrastructure/ \u2014 Repository implementations (currently ${me(i)})
12
- */
13
- import { Container, type AppModule, type ModuleRoutes } from '@forinda/kickjs-core'
14
- import { buildRoutes } from '@forinda/kickjs-http'
15
- import { ${e.toUpperCase()}_REPOSITORY } from './domain/repositories/${t}.repository'
16
- import { ${a} } from './infrastructure/repositories/${c}.repository'
17
- import { ${e}Controller } from './presentation/${t}.controller'
18
-
19
- // Eagerly load decorated classes so @Service()/@Repository() decorators register in the DI container
20
- import.meta.glob(
21
- ['./domain/services/**/*.ts', './application/use-cases/**/*.ts', '!./**/*.test.ts'],
22
- { eager: true },
23
- )
24
-
25
- export class ${e}Module implements AppModule {
26
- /**
27
- * Register module dependencies in the DI container.
28
- * Bind repository interface tokens to their implementations here.
29
- * Currently wired to ${me(i)}. To swap implementations, change the factory target.
30
- */
31
- register(container: Container): void {
32
- container.registerFactory(${e.toUpperCase()}_REPOSITORY, () =>
33
- container.resolve(${a}),
34
- )
35
- }
36
-
37
- /**
38
- * Declare HTTP routes for this module.
39
- * The path is prefixed with the global apiPrefix and version (e.g. /api/v1/${o}).
40
- * Passing 'controller' enables automatic OpenAPI spec generation via SwaggerAdapter.
41
- */
42
- routes(): ModuleRoutes {
43
- return {
44
- path: '/${o}',
45
- router: buildRoutes(${e}Controller),
46
- controller: ${e}Controller,
47
- }
48
- }
49
- }
50
- `}s(G,"generateModuleIndex");function Q(r){let{pascal:e,kebab:t,plural:o="",repo:i}=r,{repoClass:a,repoFile:c}=fe(e,t,i);return`/**
51
- * ${e} Module
52
- *
53
- * REST module with a flat folder structure.
54
- * Controller delegates to service, service wraps the repository.
55
- *
56
- * Structure:
57
- * ${t}.controller.ts \u2014 HTTP routes (CRUD)
58
- * ${t}.service.ts \u2014 Business logic
59
- * ${t}.repository.ts \u2014 Repository interface
60
- * ${c}.repository.ts \u2014 Repository implementation
61
- * dtos/ \u2014 Request/response schemas
62
- */
63
- import { Container, type AppModule, type ModuleRoutes } from '@forinda/kickjs-core'
64
- import { buildRoutes } from '@forinda/kickjs-http'
65
- import { ${e.toUpperCase()}_REPOSITORY } from './${t}.repository'
66
- import { ${a} } from './${c}.repository'
67
- import { ${e}Controller } from './${t}.controller'
68
-
69
- // Eagerly load decorated classes so @Service()/@Repository() decorators register in the DI container
70
- import.meta.glob(['./**/*.service.ts', './**/*.repository.ts', '!./**/*.test.ts'], { eager: true })
71
-
72
- export class ${e}Module implements AppModule {
73
- register(container: Container): void {
74
- container.registerFactory(${e.toUpperCase()}_REPOSITORY, () =>
75
- container.resolve(${a}),
76
- )
77
- }
78
-
79
- routes(): ModuleRoutes {
80
- return {
81
- path: '/${o}',
82
- router: buildRoutes(${e}Controller),
83
- controller: ${e}Controller,
84
- }
85
- }
86
- }
87
- `}s(Q,"generateRestModuleIndex");function L(r){let{pascal:e,kebab:t,plural:o=""}=r;return`import { type AppModule, type ModuleRoutes } from '@forinda/kickjs-core'
88
- import { buildRoutes } from '@forinda/kickjs-http'
89
- import { ${e}Controller } from './${t}.controller'
90
-
91
- export class ${e}Module implements AppModule {
92
- routes(): ModuleRoutes {
93
- return {
94
- path: '/${o}',
95
- router: buildRoutes(${e}Controller),
96
- controller: ${e}Controller,
97
- }
98
- }
99
- }
100
- `}s(L,"generateMinimalModuleIndex");function N(r){let{pascal:e,kebab:t,plural:o="",pluralPascal:i=""}=r;return`import { Controller, Get, Post, Put, Delete, Autowired, ApiQueryParams } from '@forinda/kickjs-core'
101
- import type { RequestContext } from '@forinda/kickjs-http'
102
- import { ApiTags } from '@forinda/kickjs-swagger'
103
- import { Create${e}UseCase } from '../application/use-cases/create-${t}.use-case'
104
- import { Get${e}UseCase } from '../application/use-cases/get-${t}.use-case'
105
- import { List${i}UseCase } from '../application/use-cases/list-${o}.use-case'
106
- import { Update${e}UseCase } from '../application/use-cases/update-${t}.use-case'
107
- import { Delete${e}UseCase } from '../application/use-cases/delete-${t}.use-case'
108
- import { create${e}Schema } from '../application/dtos/create-${t}.dto'
109
- import { update${e}Schema } from '../application/dtos/update-${t}.dto'
110
- import { ${e.toUpperCase()}_QUERY_CONFIG } from '../constants'
111
-
112
- @Controller()
113
- export class ${e}Controller {
114
- @Autowired() private create${e}UseCase!: Create${e}UseCase
115
- @Autowired() private get${e}UseCase!: Get${e}UseCase
116
- @Autowired() private list${i}UseCase!: List${i}UseCase
117
- @Autowired() private update${e}UseCase!: Update${e}UseCase
118
- @Autowired() private delete${e}UseCase!: Delete${e}UseCase
119
-
120
- @Get('/')
121
- @ApiTags('${e}')
122
- @ApiQueryParams(${e.toUpperCase()}_QUERY_CONFIG)
123
- async list(ctx: RequestContext) {
124
- return ctx.paginate(
125
- (parsed) => this.list${i}UseCase.execute(parsed),
126
- ${e.toUpperCase()}_QUERY_CONFIG,
127
- )
128
- }
129
-
130
- @Get('/:id')
131
- @ApiTags('${e}')
132
- async getById(ctx: RequestContext) {
133
- const result = await this.get${e}UseCase.execute(ctx.params.id)
134
- if (!result) return ctx.notFound('${e} not found')
135
- ctx.json(result)
136
- }
137
-
138
- @Post('/', { body: create${e}Schema, name: 'Create${e}' })
139
- @ApiTags('${e}')
140
- async create(ctx: RequestContext) {
141
- const result = await this.create${e}UseCase.execute(ctx.body)
142
- ctx.created(result)
143
- }
144
-
145
- @Put('/:id', { body: update${e}Schema, name: 'Update${e}' })
146
- @ApiTags('${e}')
147
- async update(ctx: RequestContext) {
148
- const result = await this.update${e}UseCase.execute(ctx.params.id, ctx.body)
149
- ctx.json(result)
150
- }
151
-
152
- @Delete('/:id')
153
- @ApiTags('${e}')
154
- async remove(ctx: RequestContext) {
155
- await this.delete${e}UseCase.execute(ctx.params.id)
156
- ctx.noContent()
157
- }
158
- }
159
- `}s(N,"generateController");function W(r){let{pascal:e,kebab:t,plural:o="",pluralPascal:i=""}=r,a=e.charAt(0).toLowerCase()+e.slice(1);return`import { Controller, Get, Post, Put, Delete, Autowired, ApiQueryParams } from '@forinda/kickjs-core'
160
- import type { RequestContext } from '@forinda/kickjs-http'
161
- import { ApiTags } from '@forinda/kickjs-swagger'
162
- import { ${e}Service } from './${t}.service'
163
- import { create${e}Schema } from './dtos/create-${t}.dto'
164
- import { update${e}Schema } from './dtos/update-${t}.dto'
165
- import { ${e.toUpperCase()}_QUERY_CONFIG } from './${t}.constants'
166
-
167
- @Controller()
168
- export class ${e}Controller {
169
- @Autowired() private ${a}Service!: ${e}Service
170
-
171
- @Get('/')
172
- @ApiTags('${e}')
173
- @ApiQueryParams(${e.toUpperCase()}_QUERY_CONFIG)
174
- async list(ctx: RequestContext) {
175
- return ctx.paginate(
176
- (parsed) => this.${a}Service.findPaginated(parsed),
177
- ${e.toUpperCase()}_QUERY_CONFIG,
178
- )
179
- }
180
-
181
- @Get('/:id')
182
- @ApiTags('${e}')
183
- async getById(ctx: RequestContext) {
184
- const result = await this.${a}Service.findById(ctx.params.id)
185
- if (!result) return ctx.notFound('${e} not found')
186
- ctx.json(result)
187
- }
188
-
189
- @Post('/', { body: create${e}Schema, name: 'Create${e}' })
190
- @ApiTags('${e}')
191
- async create(ctx: RequestContext) {
192
- const result = await this.${a}Service.create(ctx.body)
193
- ctx.created(result)
194
- }
195
-
196
- @Put('/:id', { body: update${e}Schema, name: 'Update${e}' })
197
- @ApiTags('${e}')
198
- async update(ctx: RequestContext) {
199
- const result = await this.${a}Service.update(ctx.params.id, ctx.body)
200
- ctx.json(result)
201
- }
202
-
203
- @Delete('/:id')
204
- @ApiTags('${e}')
205
- async remove(ctx: RequestContext) {
206
- await this.${a}Service.delete(ctx.params.id)
207
- ctx.noContent()
208
- }
209
- }
210
- `}s(W,"generateRestController");function B(r){let{pascal:e}=r;return`import type { QueryParamsConfig } from '@forinda/kickjs-core'
211
-
212
- export const ${e.toUpperCase()}_QUERY_CONFIG: QueryParamsConfig = {
213
- filterable: ['name'],
214
- sortable: ['name', 'createdAt'],
215
- searchable: ['name'],
216
- }
217
- `}s(B,"generateConstants");function C(r){let{pascal:e,kebab:t}=r;return`import { z } from 'zod'
218
-
219
- /**
220
- * Create ${e} DTO \u2014 Zod schema for validating POST request bodies.
221
- * This schema is passed to @Post('/', { body: create${e}Schema }) for automatic validation.
222
- * It also generates OpenAPI request body docs when SwaggerAdapter is used.
223
- *
224
- * Add more fields as needed. Supported Zod types:
225
- * z.string(), z.number(), z.boolean(), z.enum([...]),
226
- * z.array(), z.object(), .optional(), .default(), .transform()
227
- */
228
- export const create${e}Schema = z.object({
229
- name: z.string().min(1, 'Name is required').max(200),
230
- })
231
-
232
- export type Create${e}DTO = z.infer<typeof create${e}Schema>
233
- `}s(C,"generateCreateDTO");function R(r){let{pascal:e,kebab:t}=r;return`import { z } from 'zod'
234
-
235
- export const update${e}Schema = z.object({
236
- name: z.string().min(1).max(200).optional(),
237
- })
238
-
239
- export type Update${e}DTO = z.infer<typeof update${e}Schema>
240
- `}s(R,"generateUpdateDTO");function b(r){let{pascal:e,kebab:t}=r;return`export interface ${e}ResponseDTO {
241
- id: string
242
- name: string
243
- createdAt: string
244
- updatedAt: string
245
- }
246
- `}s(b,"generateResponseDTO");function K(r){let{pascal:e,kebab:t,plural:o="",pluralPascal:i=""}=r;return[{file:`create-${t}.use-case.ts`,content:`/**
247
- * Create ${e} Use Case
248
- *
249
- * Application layer \u2014 orchestrates a single business operation.
250
- * Use cases are thin: validate input (via DTO), call domain/repo, return response.
251
- * Keep business rules in the domain service, not here.
252
- */
253
- import { Service, Inject } from '@forinda/kickjs-core'
254
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../../domain/repositories/${t}.repository'
255
- import type { Create${e}DTO } from '../dtos/create-${t}.dto'
256
- import type { ${e}ResponseDTO } from '../dtos/${t}-response.dto'
257
-
258
- @Service()
259
- export class Create${e}UseCase {
260
- constructor(
261
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
262
- ) {}
263
-
264
- async execute(dto: Create${e}DTO): Promise<${e}ResponseDTO> {
265
- return this.repo.create(dto)
266
- }
267
- }
268
- `},{file:`get-${t}.use-case.ts`,content:`import { Service, Inject } from '@forinda/kickjs-core'
269
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../../domain/repositories/${t}.repository'
270
- import type { ${e}ResponseDTO } from '../dtos/${t}-response.dto'
271
-
272
- @Service()
273
- export class Get${e}UseCase {
274
- constructor(
275
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
276
- ) {}
277
-
278
- async execute(id: string): Promise<${e}ResponseDTO | null> {
279
- return this.repo.findById(id)
280
- }
281
- }
282
- `},{file:`list-${o}.use-case.ts`,content:`import { Service, Inject } from '@forinda/kickjs-core'
283
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../../domain/repositories/${t}.repository'
284
- import type { ParsedQuery } from '@forinda/kickjs-http'
285
-
286
- @Service()
287
- export class List${i}UseCase {
288
- constructor(
289
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
290
- ) {}
291
-
292
- async execute(parsed: ParsedQuery) {
293
- return this.repo.findPaginated(parsed)
294
- }
295
- }
296
- `},{file:`update-${t}.use-case.ts`,content:`import { Service, Inject } from '@forinda/kickjs-core'
297
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../../domain/repositories/${t}.repository'
298
- import type { Update${e}DTO } from '../dtos/update-${t}.dto'
299
- import type { ${e}ResponseDTO } from '../dtos/${t}-response.dto'
300
-
301
- @Service()
302
- export class Update${e}UseCase {
303
- constructor(
304
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
305
- ) {}
306
-
307
- async execute(id: string, dto: Update${e}DTO): Promise<${e}ResponseDTO> {
308
- return this.repo.update(id, dto)
309
- }
310
- }
311
- `},{file:`delete-${t}.use-case.ts`,content:`import { Service, Inject } from '@forinda/kickjs-core'
312
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../../domain/repositories/${t}.repository'
313
-
314
- @Service()
315
- export class Delete${e}UseCase {
316
- constructor(
317
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
318
- ) {}
319
-
320
- async execute(id: string): Promise<void> {
321
- await this.repo.delete(id)
322
- }
323
- }
324
- `}]}s(K,"generateUseCases");function D(r){let{pascal:e,kebab:t,dtoPrefix:o="../../application/dtos"}=r;return`/**
325
- * ${e} Repository Interface
326
- *
327
- * Defines the contract for data access.
328
- * The interface declares what operations are available;
329
- * implementations (in-memory, Drizzle, Prisma) fulfill the contract.
330
- *
331
- * To swap implementations, change the factory in the module's register() method.
332
- */
333
- import type { ${e}ResponseDTO } from '${o}/${t}-response.dto'
334
- import type { Create${e}DTO } from '${o}/create-${t}.dto'
335
- import type { Update${e}DTO } from '${o}/update-${t}.dto'
336
- import type { ParsedQuery } from '@forinda/kickjs-http'
337
-
338
- export interface I${e}Repository {
339
- findById(id: string): Promise<${e}ResponseDTO | null>
340
- findAll(): Promise<${e}ResponseDTO[]>
341
- findPaginated(parsed: ParsedQuery): Promise<{ data: ${e}ResponseDTO[]; total: number }>
342
- create(dto: Create${e}DTO): Promise<${e}ResponseDTO>
343
- update(id: string, dto: Update${e}DTO): Promise<${e}ResponseDTO>
344
- delete(id: string): Promise<void>
345
- }
346
-
347
- export const ${e.toUpperCase()}_REPOSITORY = Symbol('I${e}Repository')
348
- `}s(D,"generateRepositoryInterface");function T(r){let{pascal:e,kebab:t,repoPrefix:o="../../domain/repositories",dtoPrefix:i="../../application/dtos"}=r;return`/**
349
- * In-Memory ${e} Repository
350
- *
351
- * Implements the repository interface using a Map.
352
- * Useful for prototyping and testing. Replace with a database implementation
353
- * (Drizzle, Prisma, etc.) for production use.
354
- *
355
- * @Repository() registers this class in the DI container as a singleton.
356
- */
357
- import { randomUUID } from 'node:crypto'
358
- import { Repository, HttpException } from '@forinda/kickjs-core'
359
- import type { ParsedQuery } from '@forinda/kickjs-http'
360
- import type { I${e}Repository } from '${o}/${t}.repository'
361
- import type { ${e}ResponseDTO } from '${i}/${t}-response.dto'
362
- import type { Create${e}DTO } from '${i}/create-${t}.dto'
363
- import type { Update${e}DTO } from '${i}/update-${t}.dto'
364
-
365
- @Repository()
366
- export class InMemory${e}Repository implements I${e}Repository {
367
- private store = new Map<string, ${e}ResponseDTO>()
368
-
369
- async findById(id: string): Promise<${e}ResponseDTO | null> {
370
- return this.store.get(id) ?? null
371
- }
372
-
373
- async findAll(): Promise<${e}ResponseDTO[]> {
374
- return Array.from(this.store.values())
375
- }
376
-
377
- async findPaginated(parsed: ParsedQuery): Promise<{ data: ${e}ResponseDTO[]; total: number }> {
378
- const all = Array.from(this.store.values())
379
- const data = all.slice(parsed.pagination.offset, parsed.pagination.offset + parsed.pagination.limit)
380
- return { data, total: all.length }
381
- }
382
-
383
- async create(dto: Create${e}DTO): Promise<${e}ResponseDTO> {
384
- const now = new Date().toISOString()
385
- const entity: ${e}ResponseDTO = {
386
- id: randomUUID(),
387
- name: dto.name,
388
- createdAt: now,
389
- updatedAt: now,
390
- }
391
- this.store.set(entity.id, entity)
392
- return entity
393
- }
394
-
395
- async update(id: string, dto: Update${e}DTO): Promise<${e}ResponseDTO> {
396
- const existing = this.store.get(id)
397
- if (!existing) throw HttpException.notFound('${e} not found')
398
- const updated = { ...existing, ...dto, updatedAt: new Date().toISOString() }
399
- this.store.set(id, updated)
400
- return updated
401
- }
402
-
403
- async delete(id: string): Promise<void> {
404
- if (!this.store.has(id)) throw HttpException.notFound('${e} not found')
405
- this.store.delete(id)
406
- }
407
- }
408
- `}s(T,"generateInMemoryRepository");function P(r){let{pascal:e,kebab:t,repoType:o="",repoPrefix:i="../../domain/repositories",dtoPrefix:a="../../application/dtos"}=r,c=o.charAt(0).toUpperCase()+o.slice(1).replace(/-([a-z])/g,(n,p)=>p.toUpperCase());return`/**
409
- * ${c} ${e} Repository
410
- *
411
- * Stub implementation for a custom '${o}' repository.
412
- * Implements the repository interface using an in-memory Map as a placeholder.
413
- *
414
- * TODO: Replace the in-memory Map with your ${o} data-access logic.
415
- * See I${e}Repository for the interface contract.
416
- *
417
- * @Repository() registers this class in the DI container as a singleton.
418
- */
419
- import { randomUUID } from 'node:crypto'
420
- import { Repository, HttpException } from '@forinda/kickjs-core'
421
- import type { ParsedQuery } from '@forinda/kickjs-http'
422
- import type { I${e}Repository } from '${i}/${t}.repository'
423
- import type { ${e}ResponseDTO } from '${a}/${t}-response.dto'
424
- import type { Create${e}DTO } from '${a}/create-${t}.dto'
425
- import type { Update${e}DTO } from '${a}/update-${t}.dto'
426
-
427
- @Repository()
428
- export class ${c}${e}Repository implements I${e}Repository {
429
- // TODO: Replace with your ${o} client/connection
430
- private store = new Map<string, ${e}ResponseDTO>()
431
-
432
- async findById(id: string): Promise<${e}ResponseDTO | null> {
433
- // TODO: Implement with ${o}
434
- return this.store.get(id) ?? null
435
- }
436
-
437
- async findAll(): Promise<${e}ResponseDTO[]> {
438
- // TODO: Implement with ${o}
439
- return Array.from(this.store.values())
440
- }
441
-
442
- async findPaginated(parsed: ParsedQuery): Promise<{ data: ${e}ResponseDTO[]; total: number }> {
443
- // TODO: Implement with ${o}
444
- const all = Array.from(this.store.values())
445
- const data = all.slice(parsed.pagination.offset, parsed.pagination.offset + parsed.pagination.limit)
446
- return { data, total: all.length }
447
- }
448
-
449
- async create(dto: Create${e}DTO): Promise<${e}ResponseDTO> {
450
- // TODO: Implement with ${o}
451
- const now = new Date().toISOString()
452
- const entity: ${e}ResponseDTO = {
453
- id: randomUUID(),
454
- name: dto.name,
455
- createdAt: now,
456
- updatedAt: now,
457
- }
458
- this.store.set(entity.id, entity)
459
- return entity
460
- }
461
-
462
- async update(id: string, dto: Update${e}DTO): Promise<${e}ResponseDTO> {
463
- // TODO: Implement with ${o}
464
- const existing = this.store.get(id)
465
- if (!existing) throw HttpException.notFound('${e} not found')
466
- const updated = { ...existing, ...dto, updatedAt: new Date().toISOString() }
467
- this.store.set(id, updated)
468
- return updated
469
- }
470
-
471
- async delete(id: string): Promise<void> {
472
- // TODO: Implement with ${o}
473
- if (!this.store.has(id)) throw HttpException.notFound('${e} not found')
474
- this.store.delete(id)
475
- }
476
- }
477
- `}s(P,"generateCustomRepository");function Y(r){let{pascal:e,kebab:t}=r;return`/**
478
- * ${e} Domain Service
479
- *
480
- * Domain layer \u2014 contains business rules that don't belong to a single entity.
481
- * Use this for cross-entity logic, validation rules, and domain invariants.
482
- * Keep it free of HTTP/framework concerns.
483
- */
484
- import { Service, Inject, HttpException } from '@forinda/kickjs-core'
485
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../repositories/${t}.repository'
486
-
487
- @Service()
488
- export class ${e}DomainService {
489
- constructor(
490
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
491
- ) {}
492
-
493
- async ensureExists(id: string): Promise<void> {
494
- const entity = await this.repo.findById(id)
495
- if (!entity) {
496
- throw HttpException.notFound('${e} not found')
497
- }
498
- }
499
- }
500
- `}s(Y,"generateDomainService");function H(r){let{pascal:e,kebab:t}=r;return`/**
501
- * ${e} Entity
502
- *
503
- * Domain layer \u2014 the core business object.
504
- * Uses a private constructor with static factory methods (create, reconstitute)
505
- * to enforce invariants. Properties are accessed via getters to maintain encapsulation.
506
- *
507
- * Patterns used:
508
- * - Private constructor: prevents direct instantiation
509
- * - create(): factory for new entities (generates ID, sets timestamps)
510
- * - reconstitute(): factory for rebuilding from persistence (no side effects)
511
- * - changeName(): mutation method that enforces business rules
512
- */
513
- import { ${e}Id } from '../value-objects/${t}-id.vo'
514
-
515
- interface ${e}Props {
516
- id: ${e}Id
517
- name: string
518
- createdAt: Date
519
- updatedAt: Date
520
- }
521
-
522
- export class ${e} {
523
- private constructor(private props: ${e}Props) {}
524
-
525
- static create(params: { name: string }): ${e} {
526
- const now = new Date()
527
- return new ${e}({
528
- id: ${e}Id.create(),
529
- name: params.name,
530
- createdAt: now,
531
- updatedAt: now,
532
- })
533
- }
534
-
535
- static reconstitute(props: ${e}Props): ${e} {
536
- return new ${e}(props)
537
- }
538
-
539
- get id(): ${e}Id {
540
- return this.props.id
541
- }
542
- get name(): string {
543
- return this.props.name
544
- }
545
- get createdAt(): Date {
546
- return this.props.createdAt
547
- }
548
- get updatedAt(): Date {
549
- return this.props.updatedAt
550
- }
551
-
552
- changeName(name: string): void {
553
- if (!name || name.trim().length === 0) {
554
- throw new Error('Name cannot be empty')
555
- }
556
- this.props.name = name.trim()
557
- this.props.updatedAt = new Date()
558
- }
559
-
560
- toJSON() {
561
- return {
562
- id: this.props.id.toString(),
563
- name: this.props.name,
564
- createdAt: this.props.createdAt.toISOString(),
565
- updatedAt: this.props.updatedAt.toISOString(),
566
- }
567
- }
568
- }
569
- `}s(H,"generateEntity");function J(r){let{pascal:e,kebab:t}=r;return`/**
570
- * ${e} ID Value Object
571
- *
572
- * Domain layer \u2014 wraps a primitive ID with type safety and validation.
573
- * Value objects are immutable and compared by value, not reference.
574
- *
575
- * ${e}Id.create() \u2014 generate a new UUID
576
- * ${e}Id.from(id) \u2014 wrap an existing ID string (validates non-empty)
577
- * id.equals(other) \u2014 compare two IDs by value
578
- */
579
- import { randomUUID } from 'node:crypto'
580
-
581
- export class ${e}Id {
582
- private constructor(private readonly value: string) {}
583
-
584
- static create(): ${e}Id {
585
- return new ${e}Id(randomUUID())
586
- }
587
-
588
- static from(id: string): ${e}Id {
589
- if (!id || id.trim().length === 0) {
590
- throw new Error('${e}Id cannot be empty')
591
- }
592
- return new ${e}Id(id)
593
- }
594
-
595
- toString(): string {
596
- return this.value
597
- }
598
-
599
- equals(other: ${e}Id): boolean {
600
- return this.value === other.value
601
- }
602
- }
603
- `}s(J,"generateValueObject");function O(r){let{pascal:e,kebab:t,plural:o=""}=r;return`import { describe, it, expect, beforeEach } from 'vitest'
604
- import { Container } from '@forinda/kickjs-core'
605
-
606
- describe('${e}Controller', () => {
607
- beforeEach(() => {
608
- Container.reset()
609
- })
610
-
611
- it('should be defined', () => {
612
- expect(true).toBe(true)
613
- })
614
-
615
- describe('POST /${o}', () => {
616
- it('should create a new ${t}', async () => {
617
- // TODO: Set up test module, call create endpoint, assert 201
618
- expect(true).toBe(true)
619
- })
620
- })
621
-
622
- describe('GET /${o}', () => {
623
- it('should return paginated ${o}', async () => {
624
- // TODO: Set up test module, call list endpoint, assert { data, meta }
625
- expect(true).toBe(true)
626
- })
627
- })
628
-
629
- describe('GET /${o}/:id', () => {
630
- it('should return a ${t} by id', async () => {
631
- // TODO: Create a ${t}, then fetch by id, assert match
632
- expect(true).toBe(true)
633
- })
634
-
635
- it('should return 404 for non-existent ${t}', async () => {
636
- // TODO: Fetch non-existent id, assert 404
637
- expect(true).toBe(true)
638
- })
639
- })
640
-
641
- describe('PUT /${o}/:id', () => {
642
- it('should update an existing ${t}', async () => {
643
- // TODO: Create, update, assert changes
644
- expect(true).toBe(true)
645
- })
646
- })
647
-
648
- describe('DELETE /${o}/:id', () => {
649
- it('should delete a ${t}', async () => {
650
- // TODO: Create, delete, assert gone
651
- expect(true).toBe(true)
652
- })
653
- })
654
- })
655
- `}s(O,"generateControllerTest");function I(r){let{pascal:e,kebab:t,plural:o="",repoPrefix:i=`../infrastructure/repositories/in-memory-${t}.repository`}=r;return`import { describe, it, expect, beforeEach } from 'vitest'
656
- import { InMemory${e}Repository } from '${i}'
657
-
658
- describe('InMemory${e}Repository', () => {
659
- let repo: InMemory${e}Repository
660
-
661
- beforeEach(() => {
662
- repo = new InMemory${e}Repository()
663
- })
664
-
665
- it('should create and retrieve a ${t}', async () => {
666
- const created = await repo.create({ name: 'Test ${e}' })
667
- expect(created).toBeDefined()
668
- expect(created.name).toBe('Test ${e}')
669
- expect(created.id).toBeDefined()
670
-
671
- const found = await repo.findById(created.id)
672
- expect(found).toEqual(created)
673
- })
674
-
675
- it('should return null for non-existent id', async () => {
676
- const found = await repo.findById('non-existent')
677
- expect(found).toBeNull()
678
- })
679
-
680
- it('should list all ${o}', async () => {
681
- await repo.create({ name: '${e} 1' })
682
- await repo.create({ name: '${e} 2' })
683
-
684
- const all = await repo.findAll()
685
- expect(all).toHaveLength(2)
686
- })
687
-
688
- it('should return paginated results', async () => {
689
- await repo.create({ name: '${e} 1' })
690
- await repo.create({ name: '${e} 2' })
691
- await repo.create({ name: '${e} 3' })
692
-
693
- const result = await repo.findPaginated({
694
- filters: [],
695
- sort: [],
696
- search: '',
697
- pagination: { page: 1, limit: 2, offset: 0 },
698
- })
699
-
700
- expect(result.data).toHaveLength(2)
701
- expect(result.total).toBe(3)
702
- })
703
-
704
- it('should update a ${t}', async () => {
705
- const created = await repo.create({ name: 'Original' })
706
- const updated = await repo.update(created.id, { name: 'Updated' })
707
- expect(updated.name).toBe('Updated')
708
- })
709
-
710
- it('should delete a ${t}', async () => {
711
- const created = await repo.create({ name: 'To Delete' })
712
- await repo.delete(created.id)
713
- const found = await repo.findById(created.id)
714
- expect(found).toBeNull()
715
- })
716
- })
717
- `}s(I,"generateRepositoryTest");function V(r){let{pascal:e,kebab:t}=r;return`import { Service, Inject, HttpException } from '@forinda/kickjs-core'
718
- import type { ParsedQuery } from '@forinda/kickjs-http'
719
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from './${t}.repository'
720
- import type { ${e}ResponseDTO } from './dtos/${t}-response.dto'
721
- import type { Create${e}DTO } from './dtos/create-${t}.dto'
722
- import type { Update${e}DTO } from './dtos/update-${t}.dto'
723
-
724
- @Service()
725
- export class ${e}Service {
726
- constructor(
727
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
728
- ) {}
729
-
730
- async findById(id: string): Promise<${e}ResponseDTO | null> {
731
- return this.repo.findById(id)
732
- }
733
-
734
- async findAll(): Promise<${e}ResponseDTO[]> {
735
- return this.repo.findAll()
736
- }
737
-
738
- async findPaginated(parsed: ParsedQuery) {
739
- return this.repo.findPaginated(parsed)
740
- }
741
-
742
- async create(dto: Create${e}DTO): Promise<${e}ResponseDTO> {
743
- return this.repo.create(dto)
744
- }
745
-
746
- async update(id: string, dto: Update${e}DTO): Promise<${e}ResponseDTO> {
747
- return this.repo.update(id, dto)
748
- }
749
-
750
- async delete(id: string): Promise<void> {
751
- await this.repo.delete(id)
752
- }
753
- }
754
- `}s(V,"generateRestService");function U(r){let{pascal:e}=r;return`import type { QueryFieldConfig } from '@forinda/kickjs-http'
755
-
756
- export const ${e.toUpperCase()}_QUERY_CONFIG: QueryFieldConfig = {
757
- filterable: ['name'],
758
- sortable: ['name', 'createdAt'],
759
- searchable: ['name'],
760
- }
761
- `}s(U,"generateRestConstants");function Z(r){let{pascal:e,kebab:t,plural:o="",repo:i}=r,a={inmemory:`InMemory${e}Repository`,drizzle:`Drizzle${e}Repository`,prisma:`Prisma${e}Repository`},c={inmemory:`in-memory-${t}`,drizzle:`drizzle-${t}`,prisma:`prisma-${t}`},n=a[i]??a.inmemory,p=c[i]??c.inmemory;return`/**
762
- * ${e} Module \u2014 CQRS Pattern
763
- *
764
- * Separates read (queries) and write (commands) operations.
765
- * Events are emitted after state changes and can be handled via
766
- * WebSocket broadcasts, queue jobs, or ETL pipelines.
767
- *
768
- * Structure:
769
- * commands/ \u2014 Write operations (create, update, delete)
770
- * queries/ \u2014 Read operations (get, list)
771
- * events/ \u2014 Domain events + handlers (WS broadcast, queue dispatch)
772
- * dtos/ \u2014 Request/response schemas
773
- */
774
- import { Container, type AppModule, type ModuleRoutes } from '@forinda/kickjs-core'
775
- import { buildRoutes } from '@forinda/kickjs-http'
776
- import { ${e.toUpperCase()}_REPOSITORY } from './${t}.repository'
777
- import { ${n} } from './${p}.repository'
778
- import { ${e}Controller } from './${t}.controller'
779
-
780
- // Eagerly load decorated classes
781
- import.meta.glob(
782
- [
783
- './commands/**/*.ts',
784
- './queries/**/*.ts',
785
- './events/**/*.ts',
786
- '!./**/*.test.ts',
787
- ],
788
- { eager: true },
789
- )
790
-
791
- export class ${e}Module implements AppModule {
792
- register(container: Container): void {
793
- container.registerFactory(${e.toUpperCase()}_REPOSITORY, () =>
794
- container.resolve(${n}),
795
- )
796
- }
797
-
798
- routes(): ModuleRoutes {
799
- return {
800
- path: '/${o}',
801
- router: buildRoutes(${e}Controller),
802
- controller: ${e}Controller,
803
- }
804
- }
805
- }
806
- `}s(Z,"generateCqrsModuleIndex");function X(r){let{pascal:e,kebab:t,plural:o="",pluralPascal:i=""}=r;return`import { Controller, Get, Post, Put, Delete, Autowired, ApiQueryParams } from '@forinda/kickjs-core'
807
- import type { RequestContext } from '@forinda/kickjs-http'
808
- import { ApiTags } from '@forinda/kickjs-swagger'
809
- import { Create${e}Command } from './commands/create-${t}.command'
810
- import { Update${e}Command } from './commands/update-${t}.command'
811
- import { Delete${e}Command } from './commands/delete-${t}.command'
812
- import { Get${e}Query } from './queries/get-${t}.query'
813
- import { List${i}Query } from './queries/list-${o}.query'
814
- import { create${e}Schema } from './dtos/create-${t}.dto'
815
- import { update${e}Schema } from './dtos/update-${t}.dto'
816
- import { ${e.toUpperCase()}_QUERY_CONFIG } from './${t}.constants'
817
-
818
- @Controller()
819
- export class ${e}Controller {
820
- @Autowired() private create${e}Command!: Create${e}Command
821
- @Autowired() private update${e}Command!: Update${e}Command
822
- @Autowired() private delete${e}Command!: Delete${e}Command
823
- @Autowired() private get${e}Query!: Get${e}Query
824
- @Autowired() private list${i}Query!: List${i}Query
825
-
826
- @Get('/')
827
- @ApiTags('${e}')
828
- @ApiQueryParams(${e.toUpperCase()}_QUERY_CONFIG)
829
- async list(ctx: RequestContext) {
830
- return ctx.paginate(
831
- (parsed) => this.list${i}Query.execute(parsed),
832
- ${e.toUpperCase()}_QUERY_CONFIG,
833
- )
834
- }
835
-
836
- @Get('/:id')
837
- @ApiTags('${e}')
838
- async getById(ctx: RequestContext) {
839
- const result = await this.get${e}Query.execute(ctx.params.id)
840
- if (!result) return ctx.notFound('${e} not found')
841
- ctx.json(result)
842
- }
843
-
844
- @Post('/', { body: create${e}Schema, name: 'Create${e}' })
845
- @ApiTags('${e}')
846
- async create(ctx: RequestContext) {
847
- const result = await this.create${e}Command.execute(ctx.body)
848
- ctx.created(result)
849
- }
850
-
851
- @Put('/:id', { body: update${e}Schema, name: 'Update${e}' })
852
- @ApiTags('${e}')
853
- async update(ctx: RequestContext) {
854
- const result = await this.update${e}Command.execute(ctx.params.id, ctx.body)
855
- ctx.json(result)
856
- }
857
-
858
- @Delete('/:id')
859
- @ApiTags('${e}')
860
- async remove(ctx: RequestContext) {
861
- await this.delete${e}Command.execute(ctx.params.id)
862
- ctx.noContent()
863
- }
864
- }
865
- `}s(X,"generateCqrsController");function ee(r){let{pascal:e,kebab:t}=r;return[{file:`create-${t}.command.ts`,content:`import { Service, Inject } from '@forinda/kickjs-core'
866
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../${t}.repository'
867
- import type { Create${e}DTO } from '../dtos/create-${t}.dto'
868
- import type { ${e}ResponseDTO } from '../dtos/${t}-response.dto'
869
- import { ${e}Events } from '../events/${t}.events'
870
-
871
- @Service()
872
- export class Create${e}Command {
873
- constructor(
874
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
875
- @Inject(${e}Events) private readonly events: ${e}Events,
876
- ) {}
877
-
878
- async execute(dto: Create${e}DTO): Promise<${e}ResponseDTO> {
879
- const result = await this.repo.create(dto)
880
- this.events.emit('${t}.created', result)
881
- return result
882
- }
883
- }
884
- `},{file:`update-${t}.command.ts`,content:`import { Service, Inject } from '@forinda/kickjs-core'
885
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../${t}.repository'
886
- import type { Update${e}DTO } from '../dtos/update-${t}.dto'
887
- import type { ${e}ResponseDTO } from '../dtos/${t}-response.dto'
888
- import { ${e}Events } from '../events/${t}.events'
889
-
890
- @Service()
891
- export class Update${e}Command {
892
- constructor(
893
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
894
- @Inject(${e}Events) private readonly events: ${e}Events,
895
- ) {}
896
-
897
- async execute(id: string, dto: Update${e}DTO): Promise<${e}ResponseDTO> {
898
- const result = await this.repo.update(id, dto)
899
- this.events.emit('${t}.updated', result)
900
- return result
901
- }
902
- }
903
- `},{file:`delete-${t}.command.ts`,content:`import { Service, Inject } from '@forinda/kickjs-core'
904
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../${t}.repository'
905
- import { ${e}Events } from '../events/${t}.events'
906
-
907
- @Service()
908
- export class Delete${e}Command {
909
- constructor(
910
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
911
- @Inject(${e}Events) private readonly events: ${e}Events,
912
- ) {}
913
-
914
- async execute(id: string): Promise<void> {
915
- await this.repo.delete(id)
916
- this.events.emit('${t}.deleted', { id })
917
- }
918
- }
919
- `}]}s(ee,"generateCqrsCommands");function te(r){let{pascal:e,kebab:t,plural:o="",pluralPascal:i=""}=r;return[{file:`get-${t}.query.ts`,content:`import { Service, Inject } from '@forinda/kickjs-core'
920
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../${t}.repository'
921
- import type { ${e}ResponseDTO } from '../dtos/${t}-response.dto'
922
-
923
- @Service()
924
- export class Get${e}Query {
925
- constructor(
926
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
927
- ) {}
928
-
929
- async execute(id: string): Promise<${e}ResponseDTO | null> {
930
- return this.repo.findById(id)
931
- }
932
- }
933
- `},{file:`list-${o}.query.ts`,content:`import { Service, Inject } from '@forinda/kickjs-core'
934
- import { ${e.toUpperCase()}_REPOSITORY, type I${e}Repository } from '../${t}.repository'
935
- import type { ParsedQuery } from '@forinda/kickjs-http'
936
-
937
- @Service()
938
- export class List${i}Query {
939
- constructor(
940
- @Inject(${e.toUpperCase()}_REPOSITORY) private readonly repo: I${e}Repository,
941
- ) {}
942
-
943
- async execute(parsed: ParsedQuery) {
944
- return this.repo.findPaginated(parsed)
945
- }
946
- }
947
- `}]}s(te,"generateCqrsQueries");function re(r){let{pascal:e,kebab:t}=r;return[{file:`${t}.events.ts`,content:`import { Service } from '@forinda/kickjs-core'
948
- import { EventEmitter } from 'node:events'
949
- import type { ${e}ResponseDTO } from '../dtos/${t}-response.dto'
950
-
951
- /**
952
- * ${e} domain event types.
953
- *
954
- * These events are emitted by commands after state changes.
955
- * Subscribe to them in event handlers for side effects:
956
- * - WebSocket broadcasts (real-time UI updates)
957
- * - Queue jobs (async processing, ETL pipelines)
958
- * - Audit logging
959
- * - Cache invalidation
960
- */
961
- export interface ${e}EventMap {
962
- '${t}.created': ${e}ResponseDTO
963
- '${t}.updated': ${e}ResponseDTO
964
- '${t}.deleted': { id: string }
965
- }
966
-
967
- @Service()
968
- export class ${e}Events {
969
- private emitter = new EventEmitter()
970
-
971
- emit<K extends keyof ${e}EventMap>(event: K, data: ${e}EventMap[K]): void {
972
- this.emitter.emit(event, data)
973
- }
974
-
975
- on<K extends keyof ${e}EventMap>(event: K, handler: (data: ${e}EventMap[K]) => void): void {
976
- this.emitter.on(event, handler)
977
- }
978
-
979
- off<K extends keyof ${e}EventMap>(event: K, handler: (data: ${e}EventMap[K]) => void): void {
980
- this.emitter.off(event, handler)
981
- }
982
- }
983
- `},{file:`on-${t}-change.handler.ts`,content:`import { Service, Autowired } from '@forinda/kickjs-core'
984
- import { ${e}Events } from './${t}.events'
985
-
986
- /**
987
- * ${e} Change Event Handler
988
- *
989
- * Reacts to domain events emitted by commands.
990
- * Wire up side effects here:
991
- *
992
- * 1. WebSocket broadcast \u2014 notify connected clients in real-time
993
- * import { WsGateway } from '@forinda/kickjs-ws'
994
- * this.ws.broadcast('${t}-channel', { event, data })
995
- *
996
- * 2. Queue dispatch \u2014 offload heavy processing to background workers
997
- * import { QueueService } from '@forinda/kickjs-queue'
998
- * this.queue.add('${t}-etl', { action: event, payload: data })
999
- *
1000
- * 3. ETL pipeline \u2014 transform and load data to external systems
1001
- * await this.etlPipeline.process(data)
1002
- */
1003
- @Service()
1004
- export class On${e}ChangeHandler {
1005
- @Autowired() private events!: ${e}Events
1006
-
1007
- // Uncomment to inject WebSocket and Queue services:
1008
- // @Autowired() private ws!: WsGateway
1009
- // @Autowired() private queue!: QueueService
1010
-
1011
- onInit(): void {
1012
- this.events.on('${t}.created', (data) => {
1013
- console.log('[${e}] Created:', data.id)
1014
- // TODO: Broadcast via WebSocket
1015
- // this.ws.broadcast('${t}-channel', { event: '${t}.created', data })
1016
- // TODO: Dispatch to queue for async processing / ETL
1017
- // this.queue.add('${t}-etl', { action: 'create', payload: data })
1018
- })
1019
-
1020
- this.events.on('${t}.updated', (data) => {
1021
- console.log('[${e}] Updated:', data.id)
1022
- // TODO: Broadcast via WebSocket
1023
- // this.ws.broadcast('${t}-channel', { event: '${t}.updated', data })
1024
- })
1025
-
1026
- this.events.on('${t}.deleted', (data) => {
1027
- console.log('[${e}] Deleted:', data.id)
1028
- // TODO: Broadcast via WebSocket
1029
- // this.ws.broadcast('${t}-channel', { event: '${t}.deleted', data })
1030
- })
1031
- }
1032
- }
1033
- `}]}s(re,"generateCqrsEvents");function S(r){let{pascal:e,kebab:t,repoPrefix:o="../../domain/repositories",dtoPrefix:i="../../application/dtos"}=r;return`/**
1034
- * Drizzle ${e} Repository
1035
- *
1036
- * Implements the repository interface using Drizzle ORM.
1037
- * Uses buildFromColumns() with Column objects for type-safe query building.
1038
- *
1039
- * TODO: Update the schema import to match your Drizzle schema file.
1040
- * TODO: Replace DRIZZLE_DB injection token with your actual database token.
1041
- *
1042
- * @Repository() registers this class in the DI container as a singleton.
1043
- */
1044
- import { eq, ne, gt, gte, lt, lte, ilike, inArray, between, and, or, asc, desc, count, sql } from 'drizzle-orm'
1045
- import { Repository, HttpException, Inject } from '@forinda/kickjs-core'
1046
- import { DRIZZLE_DB, DrizzleQueryAdapter } from '@forinda/kickjs-drizzle'
1047
- import type { ParsedQuery } from '@forinda/kickjs-http'
1048
- import type { I${e}Repository } from '${o}/${t}.repository'
1049
- import type { ${e}ResponseDTO } from '${i}/${t}-response.dto'
1050
- import type { Create${e}DTO } from '${i}/create-${t}.dto'
1051
- import type { Update${e}DTO } from '${i}/update-${t}.dto'
1052
- import { ${e.toUpperCase()}_QUERY_CONFIG } from '../../constants'
1053
-
1054
- // TODO: Import your Drizzle schema table \u2014 e.g.:
1055
- // import { ${t}s } from '@/db/schema'
1056
-
1057
- const queryAdapter = new DrizzleQueryAdapter({
1058
- eq, ne, gt, gte, lt, lte, ilike, inArray, between, and, or, asc, desc,
1059
- })
1060
-
1061
- @Repository()
1062
- export class Drizzle${e}Repository implements I${e}Repository {
1063
- constructor(@Inject(DRIZZLE_DB) private db: any) {}
1064
-
1065
- async findById(id: string): Promise<${e}ResponseDTO | null> {
1066
- // TODO: Implement with Drizzle
1067
- // const row = this.db.select().from(${t}s).where(eq(${t}s.id, id)).get()
1068
- // return row ?? null
1069
- throw new Error('Drizzle ${e} repository not yet implemented \u2014 update schema imports and queries')
1070
- }
1071
-
1072
- async findAll(): Promise<${e}ResponseDTO[]> {
1073
- // TODO: Implement with Drizzle
1074
- // return this.db.select().from(${t}s).all()
1075
- throw new Error('Drizzle ${e} repository not yet implemented')
1076
- }
1077
-
1078
- async findPaginated(parsed: ParsedQuery): Promise<{ data: ${e}ResponseDTO[]; total: number }> {
1079
- // TODO: Use buildFromColumns() with your query config for type-safe filtering
1080
- // const query = queryAdapter.buildFromColumns(parsed, ${e.toUpperCase()}_QUERY_CONFIG)
1081
- //
1082
- // const data = this.db
1083
- // .select().from(${t}s).$dynamic()
1084
- // .where(query.where).orderBy(...query.orderBy)
1085
- // .limit(query.limit).offset(query.offset).all()
1086
- //
1087
- // const totalResult = this.db
1088
- // .select({ count: count() }).from(${t}s)
1089
- // .$dynamic().where(query.where).get()
1090
- //
1091
- // return { data, total: totalResult?.count ?? 0 }
1092
- throw new Error('Drizzle ${e} repository not yet implemented')
1093
- }
1094
-
1095
- async create(dto: Create${e}DTO): Promise<${e}ResponseDTO> {
1096
- // TODO: Implement with Drizzle
1097
- // return this.db.insert(${t}s).values(dto).returning().get()
1098
- throw new Error('Drizzle ${e} repository not yet implemented')
1099
- }
1100
-
1101
- async update(id: string, dto: Update${e}DTO): Promise<${e}ResponseDTO> {
1102
- // TODO: Implement with Drizzle
1103
- // const row = this.db.update(${t}s).set(dto).where(eq(${t}s.id, id)).returning().get()
1104
- // if (!row) throw HttpException.notFound('${e} not found')
1105
- // return row
1106
- throw new Error('Drizzle ${e} repository not yet implemented')
1107
- }
1108
-
1109
- async delete(id: string): Promise<void> {
1110
- // TODO: Implement with Drizzle
1111
- // this.db.delete(${t}s).where(eq(${t}s.id, id)).run()
1112
- throw new Error('Drizzle ${e} repository not yet implemented')
1113
- }
1114
- }
1115
- `}s(S,"generateDrizzleRepository");function oe(r){let{pascal:e,kebab:t}=r;return`import type { DrizzleQueryParamsConfig } from '@forinda/kickjs-drizzle'
1116
- // TODO: Import your schema table and reference actual columns for type safety
1117
- // import { ${t}s } from '@/db/schema'
1118
-
1119
- export const ${e.toUpperCase()}_QUERY_CONFIG: DrizzleQueryParamsConfig = {
1120
- columns: {
1121
- // Replace with actual Drizzle Column references for type-safe filtering:
1122
- // name: ${t}s.name,
1123
- // status: ${t}s.status,
1124
- },
1125
- sortable: {
1126
- // name: ${t}s.name,
1127
- // createdAt: ${t}s.createdAt,
1128
- },
1129
- searchColumns: [
1130
- // ${t}s.name,
1131
- ],
1132
- }
1133
- `}s(oe,"generateDrizzleConstants");function A(r){let{pascal:e,kebab:t,repoPrefix:o="../../domain/repositories",dtoPrefix:i="../../application/dtos"}=r,a=t.replace(/-([a-z])/g,(c,n)=>n.toUpperCase());return`/**
1134
- * Prisma ${e} Repository
1135
- *
1136
- * Implements the repository interface using Prisma Client.
1137
- * Requires a PrismaClient instance injected via the DI container.
1138
- *
1139
- * Ensure your Prisma schema has a '${e}' model defined.
1140
- *
1141
- * For full Prisma field-level type safety, replace PrismaModelDelegate with your PrismaClient:
1142
- * @Inject(PRISMA_CLIENT) private prisma!: PrismaClient
1143
- *
1144
- * @Repository() registers this class in the DI container as a singleton.
1145
- */
1146
- import { Repository, HttpException, Inject } from '@forinda/kickjs-core'
1147
- import { PRISMA_CLIENT, type PrismaModelDelegate } from '@forinda/kickjs-prisma'
1148
- import type { ParsedQuery } from '@forinda/kickjs-http'
1149
- import type { I${e}Repository } from '${o}/${t}.repository'
1150
- import type { ${e}ResponseDTO } from '${i}/${t}-response.dto'
1151
- import type { Create${e}DTO } from '${i}/create-${t}.dto'
1152
- import type { Update${e}DTO } from '${i}/update-${t}.dto'
1153
-
1154
- @Repository()
1155
- export class Prisma${e}Repository implements I${e}Repository {
1156
- @Inject(PRISMA_CLIENT) private prisma!: { ${a}: PrismaModelDelegate }
1157
-
1158
- async findById(id: string): Promise<${e}ResponseDTO | null> {
1159
- return this.prisma.${a}.findUnique({ where: { id } }) as Promise<${e}ResponseDTO | null>
1160
- }
1161
-
1162
- async findAll(): Promise<${e}ResponseDTO[]> {
1163
- return this.prisma.${a}.findMany() as Promise<${e}ResponseDTO[]>
1164
- }
1165
-
1166
- async findPaginated(parsed: ParsedQuery): Promise<{ data: ${e}ResponseDTO[]; total: number }> {
1167
- const [data, total] = await Promise.all([
1168
- this.prisma.${a}.findMany({
1169
- skip: parsed.pagination.offset,
1170
- take: parsed.pagination.limit,
1171
- }) as Promise<${e}ResponseDTO[]>,
1172
- this.prisma.${a}.count(),
1173
- ])
1174
- return { data, total }
1175
- }
1176
-
1177
- async create(dto: Create${e}DTO): Promise<${e}ResponseDTO> {
1178
- return this.prisma.${a}.create({ data: dto as Record<string, unknown> }) as Promise<${e}ResponseDTO>
1179
- }
1180
-
1181
- async update(id: string, dto: Update${e}DTO): Promise<${e}ResponseDTO> {
1182
- const existing = await this.prisma.${a}.findUnique({ where: { id } })
1183
- if (!existing) throw HttpException.notFound('${e} not found')
1184
- return this.prisma.${a}.update({ where: { id }, data: dto as Record<string, unknown> }) as Promise<${e}ResponseDTO>
1185
- }
1186
-
1187
- async delete(id: string): Promise<void> {
1188
- await this.prisma.${a}.deleteMany({ where: { id } })
1189
- }
1190
- }
1191
- `}s(A,"generatePrismaRepository");async function se(r){let{pascal:e,kebab:t,plural:o,write:i}=r;await i("index.ts",L({pascal:e,kebab:t,plural:o})),await i(`${t}.controller.ts`,`import { Controller, Get } from '@forinda/kickjs-core'
1192
- import type { RequestContext } from '@forinda/kickjs-http'
1193
-
1194
- @Controller()
1195
- export class ${e}Controller {
1196
- @Get('/')
1197
- async list(ctx: RequestContext) {
1198
- ctx.json({ message: '${e} list' })
1199
- }
1200
- }
1201
- `)}s(se,"generateMinimalFiles");async function ie(r){let{pascal:e,kebab:t,plural:o,pluralPascal:i,repo:a,noTests:c,prismaClientPath:n,write:p}=r;await p("index.ts",Q({pascal:e,kebab:t,plural:o,repo:a})),await p(`${t}.constants.ts`,U({pascal:e,kebab:t})),await p(`${t}.controller.ts`,W({pascal:e,kebab:t,plural:o,pluralPascal:i})),await p(`${t}.service.ts`,V({pascal:e,kebab:t})),await p(`dtos/create-${t}.dto.ts`,C({pascal:e,kebab:t})),await p(`dtos/update-${t}.dto.ts`,R({pascal:e,kebab:t})),await p(`dtos/${t}-response.dto.ts`,b({pascal:e,kebab:t})),await p(`${t}.repository.ts`,D({pascal:e,kebab:t,dtoPrefix:"./dtos"}));let d={inmemory:`in-memory-${t}`,drizzle:`drizzle-${t}`,prisma:`prisma-${t}`},m={inmemory:s(()=>T({pascal:e,kebab:t,repoPrefix:".",dtoPrefix:"./dtos"}),"inmemory"),drizzle:s(()=>S({pascal:e,kebab:t,repoPrefix:".",dtoPrefix:"./dtos"}),"drizzle"),prisma:s(()=>A({pascal:e,kebab:t,repoPrefix:".",dtoPrefix:"./dtos",prismaClientPath:n}),"prisma")},y=d[a]??`${u(a)}-${t}`,$=m[a]??(()=>P({pascal:e,kebab:t,repoType:a,repoPrefix:".",dtoPrefix:"./dtos"}));await p(`${y}.repository.ts`,$()),c||(await p(`__tests__/${t}.controller.test.ts`,O({pascal:e,kebab:t,plural:o})),await p(`__tests__/${t}.repository.test.ts`,I({pascal:e,kebab:t,plural:o,repoPrefix:`../${d.inmemory??`in-memory-${t}`}.repository`})))}s(ie,"generateRestFiles");async function ae(r){let{pascal:e,kebab:t,plural:o,pluralPascal:i,repo:a,noTests:c,prismaClientPath:n,write:p}=r;await p("index.ts",Z({pascal:e,kebab:t,plural:o,repo:a})),await p(`${t}.constants.ts`,U({pascal:e,kebab:t})),await p(`${t}.controller.ts`,X({pascal:e,kebab:t,plural:o,pluralPascal:i})),await p(`dtos/create-${t}.dto.ts`,C({pascal:e,kebab:t})),await p(`dtos/update-${t}.dto.ts`,R({pascal:e,kebab:t})),await p(`dtos/${t}-response.dto.ts`,b({pascal:e,kebab:t}));let d=ee({pascal:e,kebab:t});for(let h of d)await p(`commands/${h.file}`,h.content);let m=te({pascal:e,kebab:t,plural:o,pluralPascal:i});for(let h of m)await p(`queries/${h.file}`,h.content);let y=re({pascal:e,kebab:t});for(let h of y)await p(`events/${h.file}`,h.content);await p(`${t}.repository.ts`,D({pascal:e,kebab:t,dtoPrefix:"./dtos"}));let $={inmemory:`in-memory-${t}`,drizzle:`drizzle-${t}`,prisma:`prisma-${t}`},x={inmemory:s(()=>T({pascal:e,kebab:t,repoPrefix:".",dtoPrefix:"./dtos"}),"inmemory"),drizzle:s(()=>S({pascal:e,kebab:t,repoPrefix:".",dtoPrefix:"./dtos"}),"drizzle"),prisma:s(()=>A({pascal:e,kebab:t,repoPrefix:".",dtoPrefix:"./dtos",prismaClientPath:n}),"prisma")},j=$[a]??`${u(a)}-${t}`,v=x[a]??(()=>P({pascal:e,kebab:t,repoType:a,repoPrefix:".",dtoPrefix:"./dtos"}));await p(`${j}.repository.ts`,v()),c||(await p(`__tests__/${t}.controller.test.ts`,O({pascal:e,kebab:t,plural:o})),await p(`__tests__/${t}.repository.test.ts`,I({pascal:e,kebab:t,plural:o,repoPrefix:`../${$.inmemory??`in-memory-${t}`}.repository`})))}s(ae,"generateCqrsFiles");async function ne(r){let{pascal:e,kebab:t,plural:o,pluralPascal:i,repo:a,noEntity:c,noTests:n,prismaClientPath:p,write:d}=r;await d("index.ts",G({pascal:e,kebab:t,plural:o,repo:a})),await d("constants.ts",a==="drizzle"?oe({pascal:e,kebab:t}):B({pascal:e,kebab:t})),await d(`presentation/${t}.controller.ts`,N({pascal:e,kebab:t,plural:o,pluralPascal:i})),await d(`application/dtos/create-${t}.dto.ts`,C({pascal:e,kebab:t})),await d(`application/dtos/update-${t}.dto.ts`,R({pascal:e,kebab:t})),await d(`application/dtos/${t}-response.dto.ts`,b({pascal:e,kebab:t}));let m=K({pascal:e,kebab:t,plural:o,pluralPascal:i});for(let v of m)await d(`application/use-cases/${v.file}`,v.content);await d(`domain/repositories/${t}.repository.ts`,D({pascal:e,kebab:t})),await d(`domain/services/${t}-domain.service.ts`,Y({pascal:e,kebab:t}));let y={inmemory:`in-memory-${t}`,drizzle:`drizzle-${t}`,prisma:`prisma-${t}`},$={inmemory:s(()=>T({pascal:e,kebab:t}),"inmemory"),drizzle:s(()=>S({pascal:e,kebab:t}),"drizzle"),prisma:s(()=>A({pascal:e,kebab:t,prismaClientPath:p}),"prisma")},x=y[a]??`${u(a)}-${t}`,j=$[a]??(()=>P({pascal:e,kebab:t,repoType:a}));await d(`infrastructure/repositories/${x}.repository.ts`,j()),c||(await d(`domain/entities/${t}.entity.ts`,H({pascal:e,kebab:t})),await d(`domain/value-objects/${t}-id.vo.ts`,J({pascal:e,kebab:t}))),n||(await d(`__tests__/${t}.controller.test.ts`,O({pascal:e,kebab:t,plural:o})),await d(`__tests__/${t}.repository.test.ts`,I({pascal:e,kebab:t,plural:o})))}s(ne,"generateDddFiles");function Be(r){let e=Le({input:process.stdin,output:process.stdout});return new Promise(t=>{e.question(r,o=>{e.close(),t(o.trim().toLowerCase())})})}s(Be,"promptUser");async function Ke(r){let{name:e,modulesDir:t,noEntity:o,noTests:i,repo:a="inmemory",force:c,dryRun:n}=r,p=r.pluralize!==!1,d=r.pattern??"ddd";r.minimal&&(d="minimal");let m=u(e),y=f(e),$=p?E(m):m,x=p?le(y):y,j=ce(t,$),v=[],h=c??!1,je=s(async(_,Ee)=>{let z=ce(j,_);if(n){v.push(z);return}if(!h&&await F(z)){let de=await Be(` File already exists: ${_}
1202
- Overwrite? (y/n/a = yes/no/all) `);if(de==="a")h=!0;else if(de!=="y"){console.log(` Skipped: ${_}`);return}}await l(z,Ee),v.push(z)},"write"),q={kebab:m,pascal:y,plural:$,pluralPascal:x,moduleDir:j,repo:a,noEntity:o??!1,noTests:i??!1,prismaClientPath:r.prismaClientPath??"@prisma/client",write:je,files:v};switch(d){case"minimal":await se(q);break;case"rest":await ie(q);break;case"cqrs":await ae(q);break;default:await ne(q);break}return n||await Ye(t,y,$),v}s(Ke,"generateModule");async function Ye(r,e,t){let o=ce(r,"index.ts");if(!await F(o)){await l(o,`import type { AppModuleClass } from '@forinda/kickjs-core'
1203
- import { ${e}Module } from './${t}'
1204
-
1205
- export const modules: AppModuleClass[] = [${e}Module]
1206
- `);return}let a=await Ne(o,"utf-8"),c=`import { ${e}Module } from './${t}'`;if(!a.includes(`${e}Module`)){let n=a.lastIndexOf("import ");if(n!==-1){let p=a.indexOf(`
1207
- `,n);a=a.slice(0,p+1)+c+`
1208
- `+a.slice(p+1)}else a=c+`
1209
- `+a;a=a.replace(/(=\s*\[)([\s\S]*?)(])/,(p,d,m,y)=>{let $=m.trim();if(!$)return`${d}${e}Module${y}`;let x=$.endsWith(",")?"":",";return`${d}${m.trimEnd()}${x} ${e}Module${y}`})}await We(o,a,"utf-8")}s(Ye,"autoRegisterModule");import{join as He}from"path";async function Je(r){let{name:e,outDir:t}=r,o=u(e),i=f(e),a=[],c=He(t,`${o}.adapter.ts`);return await l(c,`import type { Express } from 'express'
1210
- import type { AppAdapter, AdapterMiddleware, Container } from '@forinda/kickjs-core'
1211
-
1212
- export interface ${i}AdapterOptions {
1213
- // Add your adapter configuration here
1214
- }
1215
-
1216
- /**
1217
- * ${i} adapter.
1218
- *
1219
- * Hooks into the Application lifecycle to add middleware, routes,
1220
- * or external service connections.
1221
- *
1222
- * Usage:
1223
- * bootstrap({
1224
- * adapters: [new ${i}Adapter({ ... })],
1225
- * })
1226
- */
1227
- export class ${i}Adapter implements AppAdapter {
1228
- name = '${i}Adapter'
1229
-
1230
- constructor(private options: ${i}AdapterOptions = {}) {}
1231
-
1232
- /**
1233
- * Return middleware entries that the Application will mount.
1234
- * Use \`phase\` to control where in the pipeline they run:
1235
- * 'beforeGlobal' | 'afterGlobal' | 'beforeRoutes' | 'afterRoutes'
1236
- */
1237
- middleware(): AdapterMiddleware[] {
1238
- return [
1239
- // Example: add a custom header to all responses
1240
- // {
1241
- // phase: 'beforeGlobal',
1242
- // handler: (_req: any, res: any, next: any) => {
1243
- // res.setHeader('X-${i}', 'true')
1244
- // next()
1245
- // },
1246
- // },
1247
- // Example: scope middleware to a specific path
1248
- // {
1249
- // phase: 'beforeRoutes',
1250
- // path: '/api/v1/admin',
1251
- // handler: myAdminMiddleware(),
1252
- // },
1253
- ]
1254
- }
1255
-
1256
- /**
1257
- * Called before global middleware.
1258
- * Use this to mount routes that bypass the middleware stack
1259
- * (health checks, docs UI, static assets).
1260
- */
1261
- beforeMount(app: Express, container: Container): void {
1262
- // Example: mount a status route
1263
- // app.get('/${o}/status', (_req, res) => {
1264
- // res.json({ status: 'ok' })
1265
- // })
1266
- }
1267
-
1268
- /**
1269
- * Called after modules and routes are registered, before the server starts.
1270
- * Use this for late-stage DI registrations or config validation.
1271
- */
1272
- beforeStart(app: Express, container: Container): void {
1273
- // Example: register a service in the DI container
1274
- // container.registerInstance(MY_TOKEN, new MyService(this.options))
1275
- }
1276
-
1277
- /**
1278
- * Called after the HTTP server is listening.
1279
- * Use this to attach to the raw http.Server (Socket.IO, gRPC, etc).
1280
- */
1281
- afterStart(server: any, container: Container): void {
1282
- // Example: attach Socket.IO
1283
- // const io = new Server(server)
1284
- // container.registerInstance(SOCKET_IO, io)
1285
- }
1286
-
1287
- /**
1288
- * Called on graceful shutdown. Clean up connections.
1289
- */
1290
- async shutdown(): Promise<void> {
1291
- // Example: close a connection pool
1292
- // await this.pool.end()
1293
- }
1294
- }
1295
- `),a.push(c),a}s(Je,"generateAdapter");import{join as et}from"path";import{resolve as pe,join as ge}from"path";var Ve={controller:"presentation",service:"domain/services",dto:"application/dtos",guard:"presentation/guards",middleware:"middleware"},Ze={controller:"",service:"",dto:"dtos",guard:"guards",middleware:"middleware"},Xe={controller:"",service:"",dto:"dtos",guard:"guards",middleware:"middleware",command:"commands",query:"queries",event:"events"};function k(r){let{type:e,outDir:t,moduleName:o,modulesDir:i="src/modules",defaultDir:a,pattern:c="ddd"}=r;if(t)return pe(t);if(o){let n=c==="ddd"?Ve:c==="cqrs"?Xe:Ze,p=u(o),d=E(p),m=n[e]??"",y=ge(i,d);return pe(m?ge(y,m):y)}return pe(a)}s(k,"resolveOutDir");async function tt(r){let{name:e,moduleName:t,modulesDir:o,pattern:i}=r,a=k({type:"middleware",outDir:r.outDir,moduleName:t,modulesDir:o,defaultDir:"src/middleware",pattern:i}),c=u(e),n=w(e),p=[],d=et(a,`${c}.middleware.ts`);return await l(d,`import type { Request, Response, NextFunction } from 'express'
1296
-
1297
- export interface ${f(e)}Options {
1298
- // Add configuration options here
1299
- }
1300
-
1301
- /**
1302
- * ${f(e)} middleware.
1303
- *
1304
- * Usage in bootstrap:
1305
- * middleware: [${n}()]
1306
- *
1307
- * Usage with adapter:
1308
- * middleware() { return [{ handler: ${n}(), phase: 'afterGlobal' }] }
1309
- *
1310
- * Usage with @Middleware decorator:
1311
- * @Middleware(${n}())
1312
- */
1313
- export function ${n}(options: ${f(e)}Options = {}) {
1314
- return (req: Request, res: Response, next: NextFunction) => {
1315
- // Implement your middleware logic here
1316
- next()
1317
- }
1318
- }
1319
- `),p.push(d),p}s(tt,"generateMiddleware");import{join as rt}from"path";async function ot(r){let{name:e,moduleName:t,modulesDir:o,pattern:i}=r,a=k({type:"guard",outDir:r.outDir,moduleName:t,modulesDir:o,defaultDir:"src/guards",pattern:i}),c=u(e),n=w(e),p=f(e),d=[],m=rt(a,`${c}.guard.ts`);return await l(m,`import { Container, HttpException } from '@forinda/kickjs-core'
1320
- import type { RequestContext } from '@forinda/kickjs-http'
1321
-
1322
- /**
1323
- * ${p} guard.
1324
- *
1325
- * Guards protect routes by checking conditions before the handler runs.
1326
- * Return early with an error response to block access.
1327
- *
1328
- * Usage:
1329
- * @Middleware(${n}Guard)
1330
- * @Get('/protected')
1331
- * async handler(ctx: RequestContext) { ... }
1332
- */
1333
- export async function ${n}Guard(ctx: RequestContext, next: () => void): Promise<void> {
1334
- // Example: check for an authorization header
1335
- const header = ctx.headers.authorization
1336
- if (!header?.startsWith('Bearer ')) {
1337
- ctx.res.status(401).json({ message: 'Missing or invalid authorization header' })
1338
- return
1339
- }
1340
-
1341
- const token = header.slice(7)
1342
-
1343
- try {
1344
- // Verify the token using a service from the DI container
1345
- // const container = Container.getInstance()
1346
- // const authService = container.resolve(AuthService)
1347
- // const payload = authService.verifyToken(token)
1348
- // ctx.set('auth', payload)
1349
-
1350
- next()
1351
- } catch {
1352
- ctx.res.status(401).json({ message: 'Invalid or expired token' })
1353
- }
1354
- }
1355
- `),d.push(m),d}s(ot,"generateGuard");import{join as st}from"path";async function it(r){let{name:e,moduleName:t,modulesDir:o,pattern:i}=r,a=k({type:"service",outDir:r.outDir,moduleName:t,modulesDir:o,defaultDir:"src/services",pattern:i}),c=u(e),n=f(e),p=[],d=st(a,`${c}.service.ts`);return await l(d,`import { Service } from '@forinda/kickjs-core'
1356
-
1357
- @Service()
1358
- export class ${n}Service {
1359
- // Inject dependencies via constructor
1360
- // constructor(
1361
- // @Inject(MY_REPO) private readonly repo: IMyRepository,
1362
- // ) {}
1363
- }
1364
- `),p.push(d),p}s(it,"generateService");import{join as at}from"path";async function nt(r){let{name:e,moduleName:t,modulesDir:o,pattern:i}=r,a=k({type:"controller",outDir:r.outDir,moduleName:t,modulesDir:o,defaultDir:"src/controllers",pattern:i}),c=u(e),n=f(e),p=[],d=at(a,`${c}.controller.ts`);return await l(d,`import { Controller, Get, Post, Autowired } from '@forinda/kickjs-core'
1365
- import type { RequestContext } from '@forinda/kickjs-http'
1366
-
1367
- @Controller()
1368
- export class ${n}Controller {
1369
- // @Autowired() private myService!: MyService
1370
-
1371
- @Get('/')
1372
- async list(ctx: RequestContext) {
1373
- ctx.json({ message: '${n} list' })
1374
- }
1375
-
1376
- @Post('/')
1377
- async create(ctx: RequestContext) {
1378
- ctx.created({ message: '${n} created', data: ctx.body })
1379
- }
1380
- }
1381
- `),p.push(d),p}s(nt,"generateController");import{join as ct}from"path";async function pt(r){let{name:e,moduleName:t,modulesDir:o,pattern:i}=r,a=k({type:"dto",outDir:r.outDir,moduleName:t,modulesDir:o,defaultDir:"src/dtos",pattern:i}),c=u(e),n=f(e),p=w(e),d=[],m=ct(a,`${c}.dto.ts`);return await l(m,`import { z } from 'zod'
1382
-
1383
- export const ${p}Schema = z.object({
1384
- // Define your schema fields here
1385
- name: z.string().min(1).max(200),
1386
- })
1387
-
1388
- export type ${n}DTO = z.infer<typeof ${p}Schema>
1389
- `),d.push(m),d}s(pt,"generateDto");import{join as g,dirname as dt}from"path";import{execSync as M}from"child_process";import{readFileSync as lt}from"fs";import{fileURLToPath as mt}from"url";function ye(r,e,t){let o={"@forinda/kickjs-core":t,"@forinda/kickjs-http":t,"@forinda/kickjs-config":t,express:"^5.1.0","reflect-metadata":"^0.2.2",zod:"^4.3.6",pino:"^10.3.1","pino-pretty":"^13.1.3"};return e!=="minimal"&&(o["@forinda/kickjs-swagger"]=t,o["@forinda/kickjs-devtools"]=t),e==="graphql"&&(o["@forinda/kickjs-graphql"]=t,o.graphql="^16.11.0"),e==="cqrs"&&(o["@forinda/kickjs-queue"]=t,o["@forinda/kickjs-ws"]=t,o["@forinda/kickjs-otel"]=t),e==="ddd"&&(o["@forinda/kickjs-swagger"]=t),JSON.stringify({name:r,version:t.replace("^",""),type:"module",scripts:{dev:"kick dev","dev:debug":"kick dev:debug",build:"kick build",start:"kick start",test:"vitest run","test:watch":"vitest",typecheck:"tsc --noEmit",lint:"eslint src/",format:"prettier --write src/"},dependencies:o,devDependencies:{"@forinda/kickjs-cli":t,"@swc/core":"^1.7.28","@types/express":"^5.0.6","@types/node":"^24.5.2","unplugin-swc":"^1.5.9",vite:"^7.3.1","vite-node":"^5.3.0",vitest:"^3.2.4",typescript:"^5.9.2",prettier:"^3.8.1"}},null,2)}s(ye,"generatePackageJson");function $e(){return`import { defineConfig } from 'vite'
1390
- import { resolve } from 'path'
1391
- import swc from 'unplugin-swc'
1392
-
1393
- export default defineConfig({
1394
- plugins: [swc.vite()],
1395
- resolve: {
1396
- alias: {
1397
- '@': resolve(__dirname, 'src'),
1398
- },
1399
- },
1400
- server: {
1401
- watch: { usePolling: false },
1402
- hmr: true,
1403
- },
1404
- build: {
1405
- target: 'node20',
1406
- ssr: true,
1407
- outDir: 'dist',
1408
- sourcemap: true,
1409
- rollupOptions: {
1410
- input: resolve(__dirname, 'src/index.ts'),
1411
- output: { format: 'esm' },
1412
- },
1413
- },
1414
- })
1415
- `}s($e,"generateViteConfig");function he(){return JSON.stringify({compilerOptions:{target:"ES2022",module:"ESNext",moduleResolution:"bundler",lib:["ES2022"],types:["node","vite/client"],strict:!0,esModuleInterop:!0,skipLibCheck:!0,sourceMap:!0,declaration:!0,experimentalDecorators:!0,emitDecoratorMetadata:!0,outDir:"dist",rootDir:"src",paths:{"@/*":["./src/*"]}},include:["src"]},null,2)}s(he,"generateTsConfig");function ke(){return JSON.stringify({semi:!1,singleQuote:!0,trailingComma:"all",printWidth:100,tabWidth:2},null,2)}s(ke,"generatePrettierConfig");function ve(){return`# https://editorconfig.org
1416
- root = true
1417
-
1418
- [*]
1419
- indent_style = space
1420
- indent_size = 2
1421
- end_of_line = lf
1422
- charset = utf-8
1423
- trim_trailing_whitespace = true
1424
- insert_final_newline = true
1425
-
1426
- [*.md]
1427
- trim_trailing_whitespace = false
1428
- `}s(ve,"generateEditorConfig");function xe(){return`node_modules/
1429
- dist/
1430
- .env
1431
- coverage/
1432
- .DS_Store
1433
- *.tsbuildinfo
1434
- `}s(xe,"generateGitIgnore");function we(){return`# Auto-detect text files and normalise line endings to LF
1435
- * text=auto eol=lf
1436
-
1437
- # Explicitly mark generated / binary files
1438
- *.png binary
1439
- *.jpg binary
1440
- *.jpeg binary
1441
- *.gif binary
1442
- *.ico binary
1443
- *.woff binary
1444
- *.woff2 binary
1445
- *.ttf binary
1446
- *.eot binary
1447
-
1448
- # Lock files \u2014 treat as generated
1449
- pnpm-lock.yaml -diff linguist-generated
1450
- yarn.lock -diff linguist-generated
1451
- package-lock.json -diff linguist-generated
1452
- `}s(we,"generateGitAttributes");function Ce(){return`PORT=3000
1453
- NODE_ENV=development
1454
- `}s(Ce,"generateEnv");function Re(){return`PORT=3000
1455
- NODE_ENV=development
1456
- `}s(Re,"generateEnvExample");function be(){return`import { defineConfig } from 'vitest/config'
1457
- import swc from 'unplugin-swc'
1458
-
1459
- export default defineConfig({
1460
- plugins: [swc.vite()],
1461
- test: {
1462
- globals: true,
1463
- environment: 'node',
1464
- include: ['src/**/*.test.ts'],
1465
- },
1466
- })
1467
- `}s(be,"generateVitestConfig");function De(r,e,t){switch(e){case"graphql":return`import 'reflect-metadata'
1468
- import { bootstrap } from '@forinda/kickjs-http'
1469
- import { DevToolsAdapter } from '@forinda/kickjs-devtools'
1470
- import { GraphQLAdapter } from '@forinda/kickjs-graphql'
1471
- import { modules } from './modules'
1472
-
1473
- // Import your resolvers here
1474
- // import { UserResolver } from './resolvers/user.resolver'
1475
-
1476
- bootstrap({
1477
- modules,
1478
- adapters: [
1479
- new DevToolsAdapter(),
1480
- new GraphQLAdapter({
1481
- resolvers: [/* UserResolver */],
1482
- // Add custom type definitions here:
1483
- // typeDefs: userTypeDefs,
1484
- }),
1485
- ],
1486
- })
1487
- `;case"cqrs":return`import 'reflect-metadata'
1488
- import { bootstrap } from '@forinda/kickjs-http'
1489
- import { DevToolsAdapter } from '@forinda/kickjs-devtools'
1490
- import { SwaggerAdapter } from '@forinda/kickjs-swagger'
1491
- import { OtelAdapter } from '@forinda/kickjs-otel'
1492
- // import { WsAdapter } from '@forinda/kickjs-ws'
1493
- // import { QueueAdapter, BullMQProvider } from '@forinda/kickjs-queue'
1494
- import { modules } from './modules'
1495
-
1496
- bootstrap({
1497
- modules,
1498
- adapters: [
1499
- new OtelAdapter({ serviceName: '${r}' }),
1500
- new DevToolsAdapter(),
1501
- new SwaggerAdapter({
1502
- info: { title: '${r}', version: '${t}' },
1503
- }),
1504
- // Uncomment for WebSocket support:
1505
- // new WsAdapter(),
1506
- // Uncomment when Redis is available:
1507
- // new QueueAdapter({
1508
- // provider: new BullMQProvider({ host: 'localhost', port: 6379 }),
1509
- // }),
1510
- ],
1511
- })
1512
- `;case"minimal":return`import 'reflect-metadata'
1513
- import { bootstrap } from '@forinda/kickjs-http'
1514
- import { modules } from './modules'
1515
-
1516
- bootstrap({ modules })
1517
- `;default:return`import 'reflect-metadata'
1518
- import { bootstrap } from '@forinda/kickjs-http'
1519
- import { DevToolsAdapter } from '@forinda/kickjs-devtools'
1520
- import { SwaggerAdapter } from '@forinda/kickjs-swagger'
1521
- import { modules } from './modules'
1522
-
1523
- bootstrap({
1524
- modules,
1525
- adapters: [
1526
- new DevToolsAdapter(),
1527
- new SwaggerAdapter({
1528
- info: { title: '${r}', version: '${t}' },
1529
- }),
1530
- ],
1531
- })
1532
- `}}s(De,"generateEntryFile");function Te(){return`import type { AppModuleClass } from '@forinda/kickjs-core'
1533
-
1534
- export const modules: AppModuleClass[] = []
1535
- `}s(Te,"generateModulesIndex");function Pe(r,e="inmemory"){return`import { defineConfig } from '@forinda/kickjs-cli'
1536
-
1537
- export default defineConfig({
1538
- pattern: '${r}',
1539
- modules: {
1540
- dir: 'src/modules',
1541
- repo: '${e}',
1542
- pluralize: true,
1543
- },
1544
-
1545
- commands: [
1546
- {
1547
- name: 'test',
1548
- description: 'Run tests with Vitest',
1549
- steps: 'npx vitest run',
1550
- },
1551
- {
1552
- name: 'format',
1553
- description: 'Format code with Prettier',
1554
- steps: 'npx prettier --write src/',
1555
- },
1556
- {
1557
- name: 'format:check',
1558
- description: 'Check formatting without writing',
1559
- steps: 'npx prettier --check src/',
1560
- },
1561
- {
1562
- name: 'check',
1563
- description: 'Run typecheck + format check',
1564
- steps: ['npx tsc --noEmit', 'npx prettier --check src/'],
1565
- aliases: ['verify', 'ci'],
1566
- },
1567
- ],
1568
- })
1569
- `}s(Pe,"generateKickConfig");function Oe(r,e,t){let o={rest:"REST API",graphql:"GraphQL API",ddd:"Domain-Driven Design",cqrs:"CQRS + Event-Driven",minimal:"Minimal"},i=["@forinda/kickjs-core","@forinda/kickjs-http","@forinda/kickjs-config"];return e!=="minimal"&&i.push("@forinda/kickjs-swagger","@forinda/kickjs-devtools"),e==="graphql"&&i.push("@forinda/kickjs-graphql"),e==="cqrs"&&i.push("@forinda/kickjs-queue","@forinda/kickjs-ws","@forinda/kickjs-otel"),`# ${r}
1570
-
1571
- A **${o[e]??"REST API"}** built with [KickJS](https://forinda.github.io/kick-js/) \u2014 a decorator-driven Node.js framework on Express 5 and TypeScript.
1572
-
1573
- ## Getting Started
1574
-
1575
- \`\`\`bash
1576
- ${t} install
1577
- kick dev
1578
- \`\`\`
1579
-
1580
- ## Scripts
1581
-
1582
- | Command | Description |
1583
- |---|---|
1584
- | \`kick dev\` | Start dev server with Vite HMR |
1585
- | \`kick build\` | Production build |
1586
- | \`kick start\` | Run production build |
1587
- | \`${t} run test\` | Run tests with Vitest |
1588
- | \`kick g module <name>\` | Generate a DDD module |
1589
- | \`kick g scaffold <name> <fields...>\` | Generate CRUD from field definitions |
1590
- | \`kick add <package>\` | Add a KickJS package |
1591
-
1592
- ## Project Structure
1593
-
1594
- \`\`\`
1595
- src/
1596
- \u251C\u2500\u2500 index.ts # Application entry point
1597
- \u251C\u2500\u2500 modules/ # Feature modules (controllers, services, repos)
1598
- \u2502 \u2514\u2500\u2500 index.ts # Module registry
1599
- \u2514\u2500\u2500 ...
1600
- \`\`\`
1601
-
1602
- ## Packages
1603
-
1604
- ${i.map(a=>`- \`${a}\``).join(`
1605
- `)}
1606
-
1607
- ## Adding Features
1608
-
1609
- \`\`\`bash
1610
- kick add auth # Authentication (JWT, API key, OAuth)
1611
- kick add swagger # OpenAPI documentation
1612
- kick add ws # WebSocket support
1613
- kick add queue # Background job processing
1614
- kick add mailer # Email sending
1615
- kick add cron # Scheduled tasks
1616
- kick add --list # Show all available packages
1617
- \`\`\`
1618
-
1619
- ## Environment Variables
1620
-
1621
- Copy \`.env.example\` to \`.env\` and configure:
1622
-
1623
- | Variable | Default | Description |
1624
- |---|---|---|
1625
- | \`PORT\` | \`3000\` | Server port |
1626
- | \`NODE_ENV\` | \`development\` | Environment |
1627
-
1628
- ## Learn More
1629
-
1630
- - [KickJS Documentation](https://forinda.github.io/kick-js/)
1631
- - [CLI Reference](https://forinda.github.io/kick-js/api/cli.html)
1632
- `}s(Oe,"generateReadme");function Ie(r,e,t){return`# CLAUDE.md \u2014 ${r} Development Guide
1633
-
1634
- ## Project Overview
1635
-
1636
- This is a **${{rest:"REST API",graphql:"GraphQL API",ddd:"Domain-Driven Design",cqrs:"CQRS + Event-Driven",minimal:"Minimal Express"}[e]??"REST API"}** application built with [KickJS](https://forinda.github.io/kick-js/) \u2014 a decorator-driven Node.js framework on Express 5 and TypeScript.
1637
-
1638
- ## Quick Commands
1639
-
1640
- \`\`\`bash
1641
- ${t} install # Install dependencies
1642
- kick dev # Start dev server with HMR
1643
- kick build # Production build via Vite
1644
- kick start # Run production build
1645
- ${t} run test # Run tests with Vitest
1646
- ${t} run typecheck # TypeScript type checking
1647
- ${t} run format # Format code with Prettier
1648
- \`\`\`
1649
-
1650
- ## Project Structure
1651
-
1652
- \`\`\`
1653
- src/
1654
- \u251C\u2500\u2500 index.ts # Application bootstrap
1655
- \u251C\u2500\u2500 modules/ # Feature modules (DDD/CQRS pattern)
1656
- \u2502 \u2514\u2500\u2500 index.ts # Module registry
1657
- ${e==="graphql"?`\u251C\u2500\u2500 resolvers/ # GraphQL resolvers
1658
- `:""}\u2514\u2500\u2500 ...
1659
- \`\`\`
1660
-
1661
- ## Package Manager
1662
-
1663
- - Always use **${t}** for this project
1664
- - Run \`${t} install\` to sync dependencies
1665
- - Never mix package managers (npm/yarn/pnpm)
1666
-
1667
- ## Code Style
1668
-
1669
- - **Prettier** \u2014 no semicolons, single quotes, trailing commas, 100 char width
1670
- - **TypeScript strict mode** \u2014 all types required
1671
- - Format before committing: \`${t} run format\`
1672
- - Type check with: \`${t} run typecheck\`
1673
-
1674
- ## Key Patterns
1675
-
1676
- ### Controllers
1677
-
1678
- Use decorators to define routes:
1679
-
1680
- \`\`\`ts
1681
- import { Controller, Get, Post, RequestContext } from '@forinda/kickjs-http'
1682
-
1683
- @Controller('/users')
1684
- export class UserController {
1685
- @Get('/')
1686
- async findAll(ctx: RequestContext) {
1687
- return ctx.json({ users: [] })
1688
- }
1689
-
1690
- @Post('/')
1691
- async create(ctx: RequestContext) {
1692
- const data = ctx.body
1693
- return ctx.created({ user: data })
1694
- }
1695
- }
1696
- \`\`\`
1697
-
1698
- ### Services
1699
-
1700
- Inject dependencies with \`@Service()\` and \`@Autowired()\`:
1701
-
1702
- \`\`\`ts
1703
- import { Service, Autowired } from '@forinda/kickjs-core'
1704
-
1705
- @Service()
1706
- export class UserService {
1707
- @Autowired()
1708
- private userRepository!: UserRepository
1709
-
1710
- async findAll() {
1711
- return this.userRepository.findAll()
1712
- }
1713
- }
1714
- \`\`\`
1715
-
1716
- ### Modules
1717
-
1718
- Register controllers and providers in modules:
1719
-
1720
- \`\`\`ts
1721
- import { Module } from '@forinda/kickjs-core'
1722
- import { UserController } from './user.controller'
1723
- import { UserService } from './user.service'
1724
-
1725
- @Module({
1726
- controllers: [UserController],
1727
- providers: [UserService],
1728
- })
1729
- export class UserModule {}
1730
- \`\`\`
1731
-
1732
- ### RequestContext
1733
-
1734
- Every controller method receives \`ctx: RequestContext\`:
1735
-
1736
- \`\`\`ts
1737
- ctx.body // Request body (parsed JSON)
1738
- ctx.params // Route params
1739
- ctx.query // Query string
1740
- ctx.headers // Request headers
1741
- ctx.requestId // Auto-generated request ID
1742
- ctx.session // Session data (if session middleware enabled)
1743
- ctx.file // Uploaded file (single)
1744
- ctx.files // Uploaded files (multiple)
1745
-
1746
- // Pagination helpers
1747
- ctx.qs(config) // Parse query with filters/sort/pagination
1748
- ctx.paginate(handler) // Auto-paginated response
1749
-
1750
- // Response helpers
1751
- ctx.json(data) // 200 OK with JSON
1752
- ctx.created(data) // 201 Created
1753
- ctx.noContent() // 204 No Content
1754
- ctx.notFound() // 404 Not Found
1755
- ctx.badRequest(msg) // 400 Bad Request
1756
- \`\`\`
1757
-
1758
- ## CLI Generators
1759
-
1760
- Generate code with the \`kick\` CLI:
1761
-
1762
- \`\`\`bash
1763
- kick g module <name> # Full module (controller, service, DTOs, repo)
1764
- kick g scaffold <name> <fields> # CRUD module from field definitions
1765
- kick g controller <name> # Standalone controller
1766
- kick g service <name> # Service class
1767
- kick g middleware <name> # Express middleware
1768
- kick g guard <name> # Route guard (auth, roles)
1769
- kick g adapter <name> # AppAdapter with lifecycle hooks
1770
- kick g dto <name> # Zod DTO schema
1771
- ${e==="graphql"?`kick g resolver <name> # GraphQL resolver
1772
- `:""}${e==="cqrs"?`kick g job <name> # Queue job processor
1773
- `:""}\`\`\`
1774
-
1775
- ## Adding Packages
1776
-
1777
- \`\`\`bash
1778
- kick add auth # JWT, API key, OAuth strategies
1779
- kick add swagger # OpenAPI docs from decorators
1780
- kick add ws # WebSocket support
1781
- kick add queue # Background jobs (BullMQ/RabbitMQ/Kafka)
1782
- kick add mailer # Email (SMTP, Resend, SES)
1783
- kick add cron # Scheduled tasks
1784
- kick add prisma # Prisma ORM adapter
1785
- kick add drizzle # Drizzle ORM adapter
1786
- kick add otel # OpenTelemetry tracing
1787
- kick add --list # Show all available packages
1788
- \`\`\`
1789
-
1790
- ## Environment Configuration
1791
-
1792
- Edit \`.env\` for environment variables. Access them with \`@Value()\` decorator:
1793
-
1794
- \`\`\`ts
1795
- import { Value } from '@forinda/kickjs-config'
1796
-
1797
- @Service()
1798
- export class ApiService {
1799
- @Value('API_KEY')
1800
- private apiKey!: string
1801
-
1802
- @Value('PORT', 3000) // With default
1803
- private port!: number
1804
- }
1805
- \`\`\`
1806
-
1807
- Or use \`ConfigService\`:
1808
-
1809
- \`\`\`ts
1810
- import { ConfigService } from '@forinda/kickjs-config'
1811
-
1812
- @Service()
1813
- export class AppService {
1814
- @Autowired()
1815
- private config!: ConfigService
1816
-
1817
- getPort() {
1818
- return this.config.get('PORT', 3000)
1819
- }
1820
- }
1821
- \`\`\`
1822
-
1823
- ## Testing
1824
-
1825
- Tests live in \`src/**/*.test.ts\`:
1826
-
1827
- \`\`\`ts
1828
- import { describe, it, expect, beforeEach } from 'vitest'
1829
- import { Container } from '@forinda/kickjs-core'
1830
- import { createTestApp } from '@forinda/kickjs-testing'
1831
-
1832
- describe('UserController', () => {
1833
- beforeEach(() => Container.reset())
1834
-
1835
- it('should return users', async () => {
1836
- const app = await createTestApp([UserModule])
1837
- const res = await app.get('/users')
1838
- expect(res.status).toBe(200)
1839
- })
1840
- })
1841
- \`\`\`
1842
-
1843
- Run tests:
1844
- - \`${t} run test\` \u2014 run all tests
1845
- - \`${t} run test:watch\` \u2014 watch mode
1846
-
1847
- ## Decorators Reference
1848
-
1849
- ### Route Decorators
1850
- - \`@Controller('/path')\` \u2014 define controller prefix
1851
- - \`@Get('/'), @Post('/'), @Put('/'), @Delete('/'), @Patch('/')\` \u2014 HTTP methods
1852
- - \`@Middleware(fn)\` \u2014 attach middleware
1853
- - \`@Public()\` \u2014 skip authentication (requires @forinda/kickjs-auth)
1854
- - \`@Roles('admin', 'user')\` \u2014 role-based access control
1855
-
1856
- ### DI Decorators
1857
- - \`@Module({ controllers, providers, imports })\` \u2014 define module
1858
- - \`@Service()\` \u2014 singleton service (DI-registered)
1859
- - \`@Repository()\` \u2014 repository (semantic alias for @Service)
1860
- - \`@Autowired()\` \u2014 property injection
1861
- - \`@Inject('token')\` \u2014 token-based injection
1862
- - \`@Value('ENV_VAR')\` \u2014 inject config value
1863
-
1864
- ${e==="cqrs"?"### CQRS/Event Decorators\n- `@Job('job-name')` \u2014 queue job handler\n- `@Process('queue-name')` \u2014 queue processor\n- `@Cron('0 * * * *')` \u2014 cron schedule\n- `@WsController('/path')` \u2014 WebSocket controller\n- `@Subscribe('event')` \u2014 WebSocket event handler\n\n":""}${e==="graphql"?"### GraphQL Decorators\n- `@Resolver()` \u2014 GraphQL resolver\n- `@Query()` \u2014 GraphQL query\n- `@Mutation()` \u2014 GraphQL mutation\n- `@Arg('name')` \u2014 resolver argument\n\n":""}## Common Pitfalls
1865
-
1866
- 1. **Decorators fire at import time** \u2014 make sure to import module classes in \`src/modules/index.ts\`
1867
- 2. **Tests need \`Container.reset()\`** \u2014 call in \`beforeEach\` to isolate DI state
1868
- 3. **Always use \`ctx.body\`** \u2014 never \`req.body\` directly
1869
- 4. **DI requires \`reflect-metadata\`** \u2014 already imported in \`src/index.ts\`
1870
- 5. **Vite HMR requires proper cleanup** \u2014 adapters should implement \`shutdown()\`
1871
-
1872
- ## Learn More
1873
-
1874
- - [KickJS Documentation](https://forinda.github.io/kick-js/)
1875
- - [API Reference](https://forinda.github.io/kick-js/api/)
1876
- - [CLI Commands](https://forinda.github.io/kick-js/guide/cli-commands.html)
1877
- - [Decorators Guide](https://forinda.github.io/kick-js/guide/decorators.html)
1878
- `}s(Ie,"generateClaude");function Se(r,e,t){return`# AGENTS.md \u2014 AI Agent Guide for ${r}
1879
-
1880
- This guide helps AI agents (Claude, Copilot, etc.) work effectively on this KickJS application.
1881
-
1882
- ## Before You Start
1883
-
1884
- 1. Read \`CLAUDE.md\` for project conventions and commands
1885
- 2. Run \`${t} install\` to install dependencies
1886
- 3. Run \`kick dev\` to verify the app starts
1887
- 4. Read the [KickJS documentation](https://forinda.github.io/kick-js/) for framework details
1888
-
1889
- ## Where to Find Things
1890
-
1891
- ### Application Structure
1892
-
1893
- | What | Where |
1894
- |------|-------|
1895
- | Entry point | \`src/index.ts\` |
1896
- | Module registry | \`src/modules/index.ts\` |
1897
- | Feature modules | \`src/modules/<module-name>/\` |
1898
- ${e==="graphql"?"| GraphQL resolvers | `src/resolvers/` |\n":""}| Environment config | \`.env\` |
1899
- | TypeScript config | \`tsconfig.json\` |
1900
- | Vite config (HMR) | \`vite.config.ts\` |
1901
- | Vitest config | \`vitest.config.ts\` |
1902
- | Prettier config | \`.prettierrc\` |
1903
- | CLI config | \`kick.config.ts\` |
1904
-
1905
- ### Module Pattern (${e.toUpperCase()})
1906
-
1907
- Each module in \`src/modules/<name>/\` typically contains:
1908
-
1909
- ${e==="ddd"?`\`\`\`
1910
- <name>/
1911
- \u251C\u2500\u2500 <name>.controller.ts # HTTP routes (@Controller)
1912
- \u251C\u2500\u2500 <name>.service.ts # Business logic (@Service)
1913
- \u251C\u2500\u2500 <name>.repository.ts # Data access (@Repository)
1914
- \u251C\u2500\u2500 <name>.dto.ts # Request/response schemas (Zod)
1915
- \u251C\u2500\u2500 <name>.entity.ts # Domain entity (optional)
1916
- \u2514\u2500\u2500 <name>.module.ts # Module definition (@Module)
1917
- \`\`\`
1918
- `:e==="cqrs"?`\`\`\`
1919
- <name>/
1920
- \u251C\u2500\u2500 commands/ # Write operations
1921
- \u2502 \u251C\u2500\u2500 create-<name>.command.ts
1922
- \u2502 \u2514\u2500\u2500 create-<name>.handler.ts
1923
- \u251C\u2500\u2500 queries/ # Read operations
1924
- \u2502 \u251C\u2500\u2500 get-<name>.query.ts
1925
- \u2502 \u2514\u2500\u2500 get-<name>.handler.ts
1926
- \u251C\u2500\u2500 events/ # Domain events
1927
- \u2502 \u2514\u2500\u2500 <name>-created.event.ts
1928
- \u251C\u2500\u2500 <name>.controller.ts # HTTP routes
1929
- \u251C\u2500\u2500 <name>.repository.ts # Data access
1930
- \u2514\u2500\u2500 <name>.module.ts # Module definition
1931
- \`\`\`
1932
- `:e==="graphql"?"```\nresolvers/\n\u251C\u2500\u2500 <name>.resolver.ts # @Resolver, @Query, @Mutation\n\u251C\u2500\u2500 <name>.types.ts # GraphQL type definitions\n\u2514\u2500\u2500 <name>.service.ts # Business logic\n```\n":e==="rest"?`\`\`\`
1933
- <name>/
1934
- \u251C\u2500\u2500 <name>.controller.ts # HTTP routes (@Controller)
1935
- \u251C\u2500\u2500 <name>.service.ts # Business logic (@Service)
1936
- \u251C\u2500\u2500 <name>.dto.ts # Request/response schemas (Zod)
1937
- \u2514\u2500\u2500 <name>.module.ts # Module definition (@Module)
1938
- \`\`\`
1939
- `:"```\nsrc/\n\u251C\u2500\u2500 index.ts # Add routes here\n\u2514\u2500\u2500 ... # Custom structure\n```\n"}
1940
-
1941
- ## Checklist: Adding a Feature
1942
-
1943
- ### New Module (Recommended)
1944
-
1945
- Use the CLI generator for consistency:
1946
-
1947
- \`\`\`bash
1948
- kick g module <name> # Generate full module
1949
- # or
1950
- kick g scaffold <name> <fields> # Generate CRUD from fields
1951
- \`\`\`
1952
-
1953
- Then:
1954
- - [ ] Review generated files in \`src/modules/<name>/\`
1955
- - [ ] Verify module is registered in \`src/modules/index.ts\`
1956
- - [ ] Update DTOs in \`<name>.dto.ts\` if needed
1957
- - [ ] Implement business logic in \`<name>.service.ts\`
1958
- - [ ] Run \`kick dev\` to test with HMR
1959
- - [ ] Write tests in \`<name>.test.ts\`
1960
-
1961
- ### Manual Controller
1962
-
1963
- If not using generators:
1964
-
1965
- - [ ] Create \`src/modules/<name>/<name>.controller.ts\`
1966
- - [ ] Add \`@Controller('/path')\` decorator
1967
- - [ ] Add route handlers with \`@Get()\`, \`@Post()\`, etc.
1968
- - [ ] Create module file with \`@Module({ controllers: [NameController] })\`
1969
- - [ ] Register module in \`src/modules/index.ts\`
1970
- - [ ] Test with \`kick dev\`
1971
-
1972
- ### Manual Service
1973
-
1974
- - [ ] Create \`src/modules/<name>/<name>.service.ts\`
1975
- - [ ] Add \`@Service()\` decorator
1976
- - [ ] Inject dependencies with \`@Autowired()\`
1977
- - [ ] Register in module \`providers\` array
1978
- - [ ] Write unit tests
1979
-
1980
- ### New Middleware
1981
-
1982
- - [ ] Create \`src/middleware/<name>.middleware.ts\`
1983
- - [ ] Export middleware function (Express format)
1984
- - [ ] Register in \`src/index.ts\` or attach to routes with \`@Middleware()\`
1985
- - [ ] Test with sample requests
1986
-
1987
- ### Adding a Package
1988
-
1989
- Use \`kick add\` to install KickJS packages with correct peer dependencies:
1990
-
1991
- - [ ] Run \`kick add <package>\` (e.g., \`kick add auth\`)
1992
- - [ ] Follow package-specific setup in terminal output
1993
- - [ ] Update \`src/index.ts\` to register adapter (if needed)
1994
- - [ ] Configure environment variables in \`.env\`
1995
- - [ ] Test integration with \`kick dev\`
1996
-
1997
- ## Common Tasks
1998
-
1999
- ### Generate CRUD Module
2000
-
2001
- \`\`\`bash
2002
- kick g scaffold user name:string email:string age:number
2003
- \`\`\`
2004
-
2005
- This creates a full CRUD module with:
2006
- - Controller with GET, POST, PUT, DELETE routes
2007
- - Service with business logic
2008
- - Repository with data access
2009
- - DTOs with Zod validation
2010
-
2011
- ### Add Authentication
2012
-
2013
- \`\`\`bash
2014
- kick add auth
2015
- \`\`\`
2016
-
2017
- Then configure in \`src/index.ts\`:
2018
-
2019
- \`\`\`ts
2020
- import { AuthAdapter, JwtStrategy } from '@forinda/kickjs-auth'
2021
-
2022
- bootstrap({
2023
- modules,
2024
- adapters: [
2025
- new AuthAdapter({
2026
- strategies: [new JwtStrategy({ secret: process.env.JWT_SECRET! })],
2027
- }),
2028
- ],
2029
- })
2030
- \`\`\`
2031
-
2032
- ### Add Database (Prisma)
2033
-
2034
- \`\`\`bash
2035
- kick add prisma
2036
- ${t} install prisma @prisma/client
2037
- npx prisma init
2038
- # Edit prisma/schema.prisma
2039
- npx prisma migrate dev --name init
2040
- kick g module user --repo prisma
2041
- \`\`\`
2042
-
2043
- ### Add WebSocket Support
2044
-
2045
- \`\`\`bash
2046
- kick add ws
2047
- \`\`\`
2048
-
2049
- Then add adapter in \`src/index.ts\`:
2050
-
2051
- \`\`\`ts
2052
- import { WsAdapter } from '@forinda/kickjs-ws'
2053
-
2054
- bootstrap({
2055
- modules,
2056
- adapters: [new WsAdapter()],
2057
- })
2058
- \`\`\`
2059
-
2060
- Create WebSocket controller:
2061
-
2062
- \`\`\`bash
2063
- kick g controller chat --ws
2064
- \`\`\`
2065
-
2066
- ## Testing Guidelines
2067
-
2068
- All tests use Vitest:
2069
-
2070
- \`\`\`ts
2071
- import { describe, it, expect, beforeEach } from 'vitest'
2072
- import { Container } from '@forinda/kickjs-core'
2073
- import { createTestApp } from '@forinda/kickjs-testing'
2074
-
2075
- describe('UserController', () => {
2076
- beforeEach(() => {
2077
- Container.reset() // Important: isolate DI state
2078
- })
2079
-
2080
- it('should return users', async () => {
2081
- const app = await createTestApp([UserModule])
2082
- const res = await app.get('/users')
2083
-
2084
- expect(res.status).toBe(200)
2085
- expect(res.body).toHaveProperty('users')
2086
- })
2087
- })
2088
- \`\`\`
2089
-
2090
- Run tests:
2091
- - \`${t} run test\` \u2014 run all tests once
2092
- - \`${t} run test:watch\` \u2014 watch mode
2093
- - Individual file: \`${t} run test src/modules/user/user.test.ts\`
2094
-
2095
- ## Environment Variables
2096
-
2097
- Managed via \`.env\` file. Access with:
2098
-
2099
- 1. **@Value() decorator** (recommended):
2100
- \`\`\`ts
2101
- @Value('DATABASE_URL')
2102
- private dbUrl!: string
2103
- \`\`\`
2104
-
2105
- 2. **ConfigService** (for dynamic access):
2106
- \`\`\`ts
2107
- @Autowired()
2108
- private config!: ConfigService
2109
-
2110
- const port = this.config.get('PORT', 3000)
2111
- \`\`\`
2112
-
2113
- 3. **Direct access** (avoid in app code):
2114
- \`\`\`ts
2115
- process.env.PORT
2116
- \`\`\`
2117
-
2118
- ## Key Decorators
2119
-
2120
- ### HTTP Routes
2121
- | Decorator | Purpose |
2122
- |-----------|---------|
2123
- | \`@Controller('/path')\` | Define route prefix |
2124
- | \`@Get('/'), @Post('/')\` | HTTP method handlers |
2125
- | \`@Middleware(fn)\` | Attach middleware |
2126
- | \`@Public()\` | Skip auth (requires auth adapter) |
2127
- | \`@Roles('admin')\` | Role-based access |
2128
-
2129
- ### Dependency Injection
2130
- | Decorator | Purpose |
2131
- |-----------|---------|
2132
- | \`@Module({})\` | Define feature module |
2133
- | \`@Service()\` | Register singleton service |
2134
- | \`@Repository()\` | Register repository |
2135
- | \`@Autowired()\` | Property injection |
2136
- | \`@Inject('token')\` | Token-based injection |
2137
- | \`@Value('VAR')\` | Inject env variable |
2138
-
2139
- ${e==="graphql"?"### GraphQL\n| Decorator | Purpose |\n|-----------|---------|\n| `@Resolver()` | GraphQL resolver class |\n| `@Query()` | Query handler |\n| `@Mutation()` | Mutation handler |\n| `@Arg('name')` | Resolver argument |\n\n":""}${e==="cqrs"?"### Background Jobs\n| Decorator | Purpose |\n|-----------|---------|\n| `@Job('name')` | Queue job handler |\n| `@Process('queue')` | Queue processor |\n| `@Cron('0 * * * *')` | Cron schedule |\n| `@WsController()` | WebSocket controller |\n\n":""}## Common Pitfalls
2140
-
2141
- 1. **Forgot to register module** \u2014 Add to \`src/modules/index.ts\` exports array
2142
- 2. **DI not working** \u2014 Ensure \`reflect-metadata\` is imported in \`src/index.ts\`
2143
- 3. **Tests failing randomly** \u2014 Missing \`Container.reset()\` in \`beforeEach\`
2144
- 4. **Routes not found** \u2014 Check controller path and module registration
2145
- 5. **HMR not working** \u2014 Verify \`vite.config.ts\` has \`hmr: true\`
2146
- 6. **Decorators not working** \u2014 Check \`tsconfig.json\` has \`experimentalDecorators: true\`
2147
-
2148
- ## CLI Commands Reference
2149
-
2150
- | Command | Description |
2151
- |---------|-------------|
2152
- | \`kick dev\` | Dev server with HMR |
2153
- | \`kick dev:debug\` | Dev server with debugger |
2154
- | \`kick build\` | Production build |
2155
- | \`kick start\` | Run production build |
2156
- | \`kick g module <names...>\` | Generate one or more modules |
2157
- | \`kick g scaffold <name> <fields>\` | Generate CRUD |
2158
- | \`kick g controller <name>\` | Generate controller |
2159
- | \`kick g service <name>\` | Generate service |
2160
- | \`kick g middleware <name>\` | Generate middleware |
2161
- | \`kick add <package>\` | Add KickJS package |
2162
- | \`kick add --list\` | List available packages |
2163
- | \`kick rm module <names...>\` | Remove one or more modules |
2164
-
2165
- > **Note:** When using \`kick new\` in scripts or CI, pass \`-t\` (or \`--template\`) and \`-r\` (or \`--repo\`) flags to bypass interactive prompts:
2166
- > \`\`\`bash
2167
- > kick new my-api -t ddd -r prisma --pm ${t} --no-git --no-install -f
2168
- > \`\`\`
2169
-
2170
- ## Learn More
2171
-
2172
- - [KickJS Docs](https://forinda.github.io/kick-js/)
2173
- - [CLI Reference](https://forinda.github.io/kick-js/api/cli.html)
2174
- - [Decorators Guide](https://forinda.github.io/kick-js/guide/decorators.html)
2175
- - [DI System](https://forinda.github.io/kick-js/guide/dependency-injection.html)
2176
- - [Testing](https://forinda.github.io/kick-js/api/testing.html)
2177
- `}s(Se,"generateAgents");var ut=dt(mt(import.meta.url)),Ae=JSON.parse(lt(g(ut,"..","package.json"),"utf-8")),ft=`^${Ae.version}`;async function gt(r){let{name:e,directory:t,packageManager:o="pnpm",template:i="rest",defaultRepo:a="inmemory"}=r,c=t,n=s(m=>console.log(` ${m}`),"log");if(console.log(`
2178
- Creating KickJS project: ${e}
2179
- `),await l(g(c,"package.json"),ye(e,i,ft)),await l(g(c,"vite.config.ts"),$e()),await l(g(c,"tsconfig.json"),he()),await l(g(c,".prettierrc"),ke()),await l(g(c,".editorconfig"),ve()),await l(g(c,".gitignore"),xe()),await l(g(c,".gitattributes"),we()),await l(g(c,".env"),Ce()),await l(g(c,".env.example"),Re()),await l(g(c,"src/index.ts"),De(e,i,Ae.version)),await l(g(c,"src/modules/index.ts"),Te()),i==="graphql"&&await l(g(c,"src/resolvers/.gitkeep"),""),await l(g(c,"kick.config.ts"),Pe(i,a)),await l(g(c,"vitest.config.ts"),be()),await l(g(c,"README.md"),Oe(e,i,o)),await l(g(c,"CLAUDE.md"),Ie(e,i,o)),await l(g(c,"AGENTS.md"),Se(e,i,o)),r.initGit)try{M("git init",{cwd:c,stdio:"pipe"}),M("git branch -M main",{cwd:c,stdio:"pipe"}),M("git add -A",{cwd:c,stdio:"pipe"}),M('git commit -m "chore: initial commit from kick new"',{cwd:c,stdio:"pipe"}),n("Git repository initialized")}catch{n("Warning: git init failed (git may not be installed)")}if(r.installDeps){console.log(`
2180
- Installing dependencies with ${o}...
2181
- `);try{M(`${o} install`,{cwd:c,stdio:"inherit"}),console.log(`
2182
- Dependencies installed successfully!`)}catch{console.log(`
2183
- Warning: ${o} install failed. Run it manually.`)}}console.log(`
2184
- Project scaffolded successfully!`),console.log();let p=c!==process.cwd();n("Next steps:"),p&&n(` cd ${e}`),r.installDeps||n(` ${o} install`);let d={rest:"kick g module user",graphql:"kick g resolver user",ddd:"kick g module user --repo drizzle",cqrs:"kick g module user --pattern cqrs",minimal:"# add your routes to src/index.ts"};n(` ${d[i]??d.rest}`),n(" kick dev"),n(""),n("Commands:"),n(" kick dev Start dev server with Vite HMR"),n(" kick build Production build via Vite"),n(" kick start Run production build"),n(""),n("Generators:"),n(" kick g module <name> Full DDD module (controller, DTOs, use-cases, repo)"),n(" kick g scaffold <n> <f..> CRUD module from field definitions"),n(" kick g controller <name> Standalone controller"),n(" kick g service <name> @Service() class"),n(" kick g middleware <name> Express middleware"),n(" kick g guard <name> Route guard (auth, roles, etc.)"),n(" kick g adapter <name> AppAdapter with lifecycle hooks"),n(" kick g dto <name> Zod DTO schema"),i==="graphql"&&n(" kick g resolver <name> GraphQL resolver"),i==="cqrs"&&n(" kick g job <name> Queue job processor"),n(" kick g config Generate kick.config.ts"),n(""),n("Add packages:"),n(" kick add <pkg> Install a KickJS package + peers"),n(" kick add --list Show all available packages"),n(""),n("Available: auth, swagger, graphql, drizzle, prisma, ws,"),n(" cron, queue, mailer, otel, multi-tenant, notifications, testing"),n("")}s(gt,"initProject");import{readFile as yt,access as $t}from"fs/promises";import{join as ht}from"path";function kt(r){return r}s(kt,"defineConfig");var vt=["kick.config.ts","kick.config.js","kick.config.mjs","kick.config.json"];async function xt(r){for(let e of vt){let t=ht(r,e);try{await $t(t)}catch{continue}if(e.endsWith(".json")){let o=await yt(t,"utf-8");return JSON.parse(o)}try{let{pathToFileURL:o}=await import("url"),i=await import(o(t).href);return i.default??i}catch{e.endsWith(".ts")&&console.warn(`Warning: Failed to load ${e}. TypeScript config files require a runtime loader (e.g. tsx, ts-node) or use kick.config.js/.mjs instead.`);continue}}return null}s(xt,"loadKickConfig");export{kt as defineConfig,Je as generateAdapter,nt as generateController,pt as generateDto,ot as generateGuard,tt as generateMiddleware,Ke as generateModule,it as generateService,gt as initProject,xt as loadKickConfig,E as pluralize,w as toCamelCase,u as toKebabCase,f as toPascalCase};
1
+ import { _ as a, a as s, c as r, d as t, g as o, h as n, i, l as g, n as l, o as d, p as C, s as c, t as p, u as f } from "./config-11ag0rJc.js";
2
+ export {
3
+ p as defineConfig,
4
+ f as generateAdapter,
5
+ d as generateController,
6
+ s as generateDto,
7
+ r as generateGuard,
8
+ g as generateMiddleware,
9
+ t as generateModule,
10
+ c as generateService,
11
+ i as initProject,
12
+ l as loadKickConfig,
13
+ C as pluralize,
14
+ n as toCamelCase,
15
+ o as toKebabCase,
16
+ a as toPascalCase
17
+ };