generator-ddd-aggregate

    1.0.0 • Public • Published

    generator-ddd-aggregate

    Build Status

    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

    License

    MIT

    Install

    npm i generator-ddd-aggregate

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    13.3 kB

    Total Files

    12

    Last publish

    Collaborators

    • nicholaswmin