Shared DDD utils used inside Rocketseat microservices.

Usage no npm install needed!

<script type="module">
  import rocketseatDddUtils from 'https://cdn.skypack.dev/@rocketseat/ddd-utils';


DDD Utils

Shared utils to build Domain-Driven Design Node.js applications.


yarn add @rocketseat/ddd-utils

Domain utils

  • AggregateRoot: Used to add Domain Events funcionality to Entity;
  • Entity: Mark a class as a Entity;
  • UniqueEntityID: Create or gereate an unique ID using UUID;
  • ValueObject: Create a entity attribute with custom validations;
  • WatchedList: Create a list that memorize added or deleted items;

Domain events utils

  • DomainEvents: Used by Aggregate Root to add Domain Events to Entity;
  • IDomainEvent: Interface used when creating a new Domain Event;
  • IHandle: Interface used when creating a new Domain Event Handler;

Infra utils

  • BaseController: Extendable class used inside controllers in our application;
  • IMapper: Interface used when creating mappers (WIP);

Logic utils

  • AppError: Default errors caused by malfunctioning of our application;
  • Guard: Simple validation class used to validate domain entities;
  • Result: Result class, do not throw errors, use always the result class;
  • UseCaseError: Extendable class used to define a Use Case error;

Tests utils

  • BaseFakeRepo: Extendable class to create fake repositories used for testing;