Giter Site home page Giter Site logo

generator-ddd-aggregate's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.