Skip to content

Core Setup

The Core Setup is the foundational step in any DomusJS application.
It ensures that all core services, buses, and dependencies are correctly initialized before other modules or bounded contexts are registered.

✅ DomusJS provides the helper function registerDomusCore() to simplify this process.


The registerDomusCore() function sets up:

  • The Command Bus (default: InMemoryCommandBus).
  • The Query Bus (default: InMemoryQueryBus).
  • The Event Bus (default: InMemoryEventBus).
  • The Logger (default or custom).
  • Core middlewares or hooks.

It ensures that:

  • Buses are registered once and centrally.
  • Other modules can safely resolve CommandBus, QueryBus, EventBus, or Logger from the DI container.

import { registerDomusCore } from '@domusjs/infrastructure';
import { PinoLogger } from '@domusjs/infrastructure';
registerDomusCore({});

✅ This must be called before registering any other dependencies or bounded contexts.


Since many parts of your app will depend on the buses (CommandBus, QueryBus, EventBus),
you need to ensure they are initialized first, so later modules can attach handlers or middleware safely.


  • Always call registerDomusCore() at the very beginning of your app bootstrap.
  • If you replace the buses (e.g., using RabbitMQ or Google Pub/Sub),
    pass them explicitly into the setup function or register them immediately after.
  • Avoid re-registering the same core services elsewhere.