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
| Module | Package | Description |
|---|---|---|
| Command Module | @mbc-cqrs-serverless/core | CQRS command handling, data synchronization, Event Sourcing |
| Sequence Module | @mbc-cqrs-serverless/sequence | Thread-safe sequential ID generation |
| Tenant Module | @mbc-cqrs-serverless/tenant | Multi-tenant data isolation and management |
Feature Modules
| Module | Package | Description |
|---|---|---|
| Task Module | @mbc-cqrs-serverless/task | Async task execution with Step Functions |
| Master Module | @mbc-cqrs-serverless/master | Master data and settings management |
| Import Module | @mbc-cqrs-serverless/import | Large-scale CSV import with Distributed Map |
| Directory Module | @mbc-cqrs-serverless/directory | S3-backed file and folder management |
| Survey Template Module | @mbc-cqrs-serverless/survey-template | Survey template management |
Support Modules
| Module | Package | Description |
|---|---|---|
| Queue Module | @mbc-cqrs-serverless/core | SNS and SQS messaging (globally registered) |
| Notification Module | @mbc-cqrs-serverless/core | Real-time notifications via AppSync (GraphQL subscriptions default; Events API opt-in since v1.3.0) |
| Email Service | @mbc-cqrs-serverless/core | Send transactional emails via Amazon SES |
| Setting Module | @mbc-cqrs-serverless/ui-setting | User 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:
Command Module
3 items
Sequence
Generate auto-incrementing sequence numbers for business IDs with customizable formats and rotation cycles using the SequencesModule.
Task
Learn how to create and manage long-running background tasks with AWS Step Functions, task tokens, and the TasksModule.
Tenant
Learn how to use TenantModule for multi-tenant management in MBC CQRS Serverless.
Master
Learn about the Master Service for managing master data and settings in a multi-tenant environment.
Directory
Directory management module with S3 integration for file and folder management in multi-tenant serverless applications.
Import
Learn how to use ImportModule for bulk data import with CSV and ZIP file support in MBC CQRS Serverless.
Notification Module
1 item
Queue Module
Learn about the QueueModule, SnsService, and SqsService for messaging in MBC CQRS Serverless.
UI Setting
Learn how to manage UI settings and data configurations with the UI Setting module.
Related Documentation
- Command Service - CommandService detailed documentation
- Data Service - DataService query methods
- Notification Module - AppSync real-time notification documentation
- Email Service - SES email sending documentation
- Interfaces - TypeScript interfaces reference
- Modules - Available modules