https://github.com/4lessandrodev/types-generator
Generate files and module for types ddd lib
https://github.com/4lessandrodev/types-generator
Last synced: 10 months ago
JSON representation
Generate files and module for types ddd lib
- Host: GitHub
- URL: https://github.com/4lessandrodev/types-generator
- Owner: 4lessandrodev
- Created: 2021-09-05T05:13:28.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-05T23:47:04.000Z (over 4 years ago)
- Last Synced: 2025-01-07T14:22:52.254Z (12 months ago)
- Language: JavaScript
- Size: 237 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Types-ddd Generator
## This lib generate types-ddd module and files
Download the `generator` folder. Put it on you project root folder.
Execute the command on your terminal on your project root.
```shell
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](https://downgit.github.io/#/home?url=https:%2F%2Fgithub.com%2F4lessandrodev%2Ftypes-generator%2Ftree%2Fmain%2Fgenerator) or clone this repo.
### Folder structure
```shell
$ 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
```json
"scripts":{
"generate": "yarn plop --plopfile ./generator/plopfile.js"
}
```
### Install plop and types-ddd
* `$ 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 ` or
* `$ npm run generate `
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
```json
"baseUrl": "src",
"paths": {
"@modules/*":["modules/*"]
},
```
On your package.json
```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
[Click To Example](https://github.com/4lessandrodev/nest-template)