Download the generator
folder. Put it on you project root folder.
Execute the command on your terminal on your project root.
wget https://github.com/4lessandrodev/types-generator/archive/refs/heads/main.zip &&
unzip main.zip && mv ./types-generator-main/generator ./generator && rm -rf main.zip types-generator-main
You may download clicking HERE or clone this repo.
$ tree
.
├── package.json
├── README.md
└── src
├── config
│ ├── main.ts
│ └── env.ts
│
└── modules
│
└── [module-name]
│
│── domain
│ ├── value-objects
│ ├── entities
│ ├── aggregates
│ ├── events
│ ├── subscriptions
│ ├── repo
│ └── services
│
├── application
│ └── use-cases
│
└── infra
├── models
├── repo
└── mappers
Put the command below on you package.json
scripts
"scripts":{
"generate": "yarn plop --plopfile ./generator/plopfile.js"
}
$ yarn add types-ddd
or$ npm install types-ddd
$ yarn add plop -D
or$ npm install plop --dev
To generate a ddd module or resource use the command
$ yarn generate <resource-name>
or$ npm run generate <resource-name>
Example:
$ yarn generate user
If you choose module. All default files and folders for a modules will be generated on src folder.
By default import paths are set to aliases.
You can set alias on you tsconfig.json
or change your templates import paths
"baseUrl": "src",
"paths": {
"@modules/*":["modules/*"]
},
On your package.json
"_moduleAliases": {
"@modules": "./dist/modules",
}
Install module alias
$ yarn add module-alias
or $ npm install module-alias
and finally, register it on your main file, before start your server.
main.ts / app.ts or index.ts
import 'module-alias/register';
You can use the repository as example