Skip to main content

API Reference

The MBC CQRS Serverless framework provides a comprehensive set of modules for building enterprise-grade serverless applications. Each module is designed to handle specific concerns while maintaining consistency with the CQRS and Event Sourcing patterns.

Module Overview

Core Modules

ModulePackageDescription
Command Module@mbc-cqrs-serverless/coreCQRS command handling, data synchronization, Event Sourcing
Sequence Module@mbc-cqrs-serverless/sequenceThread-safe sequential ID generation
Tenant Module@mbc-cqrs-serverless/tenantMulti-tenant data isolation and management

Feature Modules

ModulePackageDescription
Task Module@mbc-cqrs-serverless/taskAsync task execution with Step Functions
Master Module@mbc-cqrs-serverless/masterMaster data and settings management
Import Module@mbc-cqrs-serverless/importLarge-scale CSV import with Distributed Map
Directory Module@mbc-cqrs-serverless/directoryS3-backed file and folder management
Survey Template Module@mbc-cqrs-serverless/survey-templateSurvey template management

Support Modules

ModulePackageDescription
Queue Module@mbc-cqrs-serverless/coreSNS and SQS messaging (globally registered)
Notification Module@mbc-cqrs-serverless/coreReal-time notifications via AppSync (GraphQL subscriptions default; Events API opt-in since v1.3.0)
Email Service@mbc-cqrs-serverless/coreSend transactional emails via Amazon SES
Setting Module@mbc-cqrs-serverless/ui-settingUser interface configuration storage

Quick Start

Install the core package:

npm install @mbc-cqrs-serverless/core

Register the CommandModule in your application:

import { Module } from '@nestjs/common';
import { CommandModule } from '@mbc-cqrs-serverless/core';

@Module({
imports: [
CommandModule.register({
tableName: 'your-table-name',
}),
],
})
export class YourModule {}

Common Patterns

Service Injection

All services are available for injection in your NestJS providers:

import { Injectable } from '@nestjs/common';
import { CommandService, DataService } from '@mbc-cqrs-serverless/core';

@Injectable()
export class YourService {
constructor(
private readonly commandService: CommandService,
private readonly dataService: DataService,
) {}
}

Multi-Tenant Context

Most operations require tenant context for data isolation:

async createItem(tenantCode: string, data: CreateDto, invokeContext: IInvoke) {
return this.commandService.publishAsync({
pk: `ITEM#${tenantCode}`,
sk: data.id,
tenantCode,
// ... other fields
}, { invokeContext });
}

Module Documentation

Explore each module's detailed documentation: