generator-ddd-aggregate
v1.0.0
Published
Generate Domain Driven Design Aggregates for Node.js
Downloads
3
Maintainers
Readme
generator-ddd-aggregate
Generate Domain Driven Design Aggregates for Node.js.
The generated Aggregate contains:
- The Base Class.
- A Repo that uses knex.js for persisting your Aggregate.
- A Service Class.
- Boilerplate tests for the Class and the Service.
Install
$ npm i -g yo
$ npm i -g generator-ddd-aggregate
Usage
The generated Aggregate is assuming the following are already installed in your parent project:
$ npm i --save guid generic-repo http-errors
$ npm i --save-dev chai mock-repo
then, the following example creates an Account Aggregate:
$ yo ddd-aggregate
# You will be asked to type the name of your aggregate, we
# are assuming you typed 'account'.
then the generator will generate the following folder structure:
account
├── classes
│ └── account
│ ├── test
│ │ ├── account.assertion.js
│ │ └── index.js
│ └── index.js
├── repos
├───────account-repo
│ └── index.js
├── account-service
│ ├── test
│ │ ├── mocks
│ │ │ └── account-repo
│ │ │ └── index.js
│ │ └── index.js
│ └── index.js
└── test
└── index.js
Composite Aggregates
Aggregates, by definition, contain more than 1 child Class. To expand to a composite Aggregate:
- Add all the relevant child classes in
classes
. - Modify your Base Class to include the relevant child classes.
- Checkout the relevant comment in
repo/index.js
on how to rewire the generated Repository to save/retrieve composite Aggregates.
Aggregate tests
Run the generated Aggregate's tests:
$ mocha account/test
Generator Test
Run this generator's tests:
$ npm test
Authors
- Nicholas Kyriakides, @nicholaswmin
License
MIT