@dawudesign/node-hexa-cli 0.2.7 → 0.2.8

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 (2) hide show
  1. package/dist/index.js +11 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -505,6 +505,7 @@ function generateContext(name) {
505
505
  dirs.forEach((dir) => {
506
506
  import_node_fs6.default.mkdirSync(import_node_path7.default.join(base, dir), { recursive: true });
507
507
  });
508
+ import_node_fs6.default.writeFileSync(import_node_path7.default.join(base, "domain/value-objects/.gitkeep"), "");
508
509
  const pascal = capitalize(name);
509
510
  const token = `${name.toUpperCase().replaceAll("-", "_")}_REPOSITORY_PORT`;
510
511
  import_node_fs6.default.writeFileSync(
@@ -536,6 +537,10 @@ import {
536
537
  } from '../../domain/ports/${name}.repository.port';
537
538
  import { randomUUID } from 'node:crypto';
538
539
 
540
+ export interface Create${pascal}Dto {
541
+ id?: string;
542
+ }
543
+
539
544
  @Injectable()
540
545
  export class Create${pascal}UseCase {
541
546
  constructor(
@@ -543,8 +548,8 @@ export class Create${pascal}UseCase {
543
548
  private readonly repository: ${pascal}RepositoryPort,
544
549
  ) {}
545
550
 
546
- async execute(id?: string): Promise<${pascal}> {
547
- const entity = new ${pascal}(id ?? randomUUID());
551
+ async execute(dto: Create${pascal}Dto = {}): Promise<${pascal}> {
552
+ const entity = new ${pascal}(dto.id ?? randomUUID());
548
553
  await this.repository.save(entity);
549
554
  return entity;
550
555
  }
@@ -553,16 +558,16 @@ export class Create${pascal}UseCase {
553
558
  );
554
559
  import_node_fs6.default.writeFileSync(
555
560
  import_node_path7.default.join(base, "infrastructure/http", `${name}.controller.ts`),
556
- `import { Controller, Post } from '@nestjs/common';
557
- import { Create${pascal}UseCase } from '../../application/use-cases/create-${name}.usecase';
561
+ `import { Body, Controller, Post } from '@nestjs/common';
562
+ import { Create${pascal}UseCase, Create${pascal}Dto } from '../../application/use-cases/create-${name}.usecase';
558
563
 
559
564
  @Controller('${name}')
560
565
  export class ${pascal}Controller {
561
566
  constructor(private readonly create${pascal}: Create${pascal}UseCase) {}
562
567
 
563
568
  @Post()
564
- async create() {
565
- return this.create${pascal}.execute();
569
+ async create(@Body() dto: Create${pascal}Dto) {
570
+ return this.create${pascal}.execute(dto);
566
571
  }
567
572
  }
568
573
  `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawudesign/node-hexa-cli",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "CLI to scaffold and analyze NestJS Hexagonal DDD projects",
5
5
  "keywords": [
6
6
  "nestjs",