@betsys-nestjs/schematics

1.3.0 • Public • Published

Getting Started With Schematics

This repository contains helper schematics for generating unified structure of NestJS components written in hexagonal architecture and CQRS pattern.

Current Schematics

Component

Generates a new component, prepares modules and nested folders (application, domain, infrastructure, ui)

Running nest g -c @betsys/nestjs-schematics component for a component named example will generate the following structure:

└── src/
    └── component/
        └── example/
            ├── application/
            │   └── example-application.module.ts
            ├── domain/
            │   └── example-domain.module.ts
            ├── infrastructure/
            │   └── example-infrastructure.module.ts
            ├── ui/
            │   ├── http/
            │   │   └── example-http.module.ts
            │   └── example-ui.module.ts
            └── example.module.ts

CQRS

Generates a command or query with a handler.

Running nest g -c @betsys/nestjs-schematics cqrs for a component named example will generate the following structure:

└── src/
    └── component/
        └── example/
            └── application/
                ├── command/
                │   ├── example-command.handler.ts
                │   └── example-command.ts
                └── query/
                    ├── example-query.handler.ts
                    └── example-query.ts

Usage

To install, simply do:

npm install --save-dev @betsys-nestjs/schematics

Then in the project start generating your code by using the nest-cli.

nest g -c @betsys/nestjs-schematics ${schematic}

That's it! The cli wizard will walk you through the configuration.

Monorepo and nested directories

By default the library works for <project-root>/src/component/<component-name> directory structure. If you are using a monorepo, you can specify the root dir by a rooDir parameter.

└── apps/
    └── my-app1/
    └── my-app2/
        └── src/
            └── component/
                └── example/
                    └── application/
                        ├── command/
                        │   ├── example-command.handler.ts
                        │   └── example-command.ts
                        └── query/
                            ├── example-query.handler.ts
                            └── example-query.ts
nest g -c @betsys/nestjs-schematics ${schematic} --rootDir=apps/my-app2

This command will generate the files in <project-root>/apps/my-app2/src/ directory.

Readme

Keywords

Package Sidebar

Install

npm i @betsys-nestjs/schematics

Weekly Downloads

8

Version

1.3.0

License

MIT

Unpacked Size

13.8 kB

Total Files

20

Last publish

Collaborators

  • betsys-development
  • pawelnowak1
  • andrejsoucek
  • jammie88
  • jiraspe2
  • jakubschneller
  • javor454
  • krizacekcz
  • flyrell