2.2.5 • Published 2 years ago

@webmogilevtsev/nestjs-ddd-cli v2.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Installation

To install the application for generating folder and file structures for your domain in a NestJS project, you can use the @webmogilevtsev/nestjs-ddd-cli package. You can install it using the following command:

npm install @webmogilevtsev/nestjs-ddd-cli --save-dev

After installing the package, you need to add a script to the package.json file to be able to run the generate:domain command. Add the following line to the "scripts" section:

"scripts": {
  ...
  "generate:domain": "ddd-cli domain --",
  "generate:command": "ddd-cli command",
  "generate:query": "ddd-cli query",
  "generate:event": "ddd-cli event"
}

Global Installation

You can also install @webmogilevtsev/nestjs-ddd-cli globally to use the generate-domain command in any NestJS project. To do this, run the following command:

npm install -g @webmogilevtsev/nestjs-ddd-cli

After the global installation, you can run the generate-domain command from any directory on your computer:

generate-domain my-name

Description

This is an application for generating folder and file structure for a domain in a NestJS project. The generate:domain command generates the folder and file structure for a new domain, including the following directories:

  • libs/domains/src/${name}-domain/application-services/commands
  • libs/domains/src/${name}-domain/application-services/dto
  • libs/domains/src/${name}-domain/application-services/events
  • libs/domains/src/${name}-domain/application-services/facade
  • libs/domains/src/${name}-domain/application-services/queries
  • libs/domains/src/${name}-domain/domain/services
  • libs/domains/src/${name}-domain/domain/repositories
  • libs/domains/src/${name}-domain/domain/sagas
  • libs/domains/src/${name}-domain/domain
  • src/infrastructure/${name}-adapter/${name}-adapter.service
  • src/infrastructure/infrastructure-module

Commands

generate:domain

Domain generation

Options:

To generate a new domain, run the generate:domain command with the name argument, which sets the domain name:

npm run generate:domain --name=my-name --format=true
# Shortened notation
npm run generate:domain my-name -f

generate:command

Command generation

Options:

To generate a new command for a domain, run the generate:command command with the name, domain, and optional --format arguments:

npm run generate:command --name=create-my-name -- --domain=my-name --format=true
# Shortened notation
npm run generate:command create-my-name -- -d my-name -f

generate:query

Query generation

Options:

To generate a new query for a domain, run the generate:query command with the name, domain, and optional --format arguments:

npm run generate:query --name=get-one-my-name -- --domain=my-name --format=true
# Shortened notation
npm run generate:query get-one-my-name -- -d my-name -f

generate:event

Event generation

Options:

To generate a new event for a domain, run the generate:event command with the name, domain, and optional --format arguments:

npm run generate:event --name=my-name-created -- --domain=my-name --format=true
# Shortened notation
npm run generate:event my-name-created -- -d my-name -f

Directory Structure

The folder and file structure created by the generate:domain command looks like this:

libs/
  domains/
    src/
      example-domain/
        application-services/
          commands/
            index.ts
          dto/
            index.ts
          events/
            index.ts
          facade/
            example-facade.factory.ts
            example-facade.service.ts
          queries/
            index.ts
        domain/
          services/
            example-domain.service.ts
          example-domain.interface.ts
          example-domain.aggregate.ts
          index.ts
        repositories/
          example-domain-repository.abstract.ts
          index.ts
        sagas/
          example-domain-saga.service.ts
        example-domain.module.ts
        index.ts
    index.ts
src/
  infrastructure/
    example-adapter/
      example-adapter.service
    infrastructure-module.ts
  • application-services/commands/ - directory with commands for managing the domain.
  • application-services/dto/ - directory with data transfer objects for use in the application.
  • application-services/events/ - directory with events emitted by the domain.
  • application-services/facade/ - directory with facade classes that provide a simple interface for interacting with the domain.
  • application-services/queries/ - directory with queries for retrieving data from the domain.
  • domain/services/ - directory with domain services that implement business logic.
  • domain/repositories/ - directory with domain repositories that provide access to data.
  • domain/sagas/ - directory with sagas that coordinate complex workflows between domain components.
  • domain/ - directory containing the domain interface, as well as aggregates and other components.
  • example-domain.module.ts - module that combines all domain components.
  • index.ts - file exporting all domains from the src/ folder.
  • infrastructure/ - implementation layer
2.3.0

2 years ago

2.2.1

2 years ago

2.1.2

2 years ago

2.2.0

2 years ago

2.2.3

2 years ago

2.1.4

2 years ago

2.2.2

2 years ago

2.1.3

2 years ago

2.2.5

2 years ago

2.2.4

2 years ago

2.1.5

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago