Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

NestJS Outbox TypeORM Driver

npm version

TypeORM driver for @fullstackhouse/nestjs-outbox.

Features

  • PostgreSQL & MySQL Support: Works with postgres and mysql drivers

Installation

npm install @fullstackhouse/nestjs-outbox-typeorm-driver

Quick Start

import { OutboxModule } from '@fullstackhouse/nestjs-outbox';
import {
  OutboxTransportEventMigrations,
  TypeORMDatabaseDriverFactory,
  TypeOrmOutboxTransportEvent,
} from '@fullstackhouse/nestjs-outbox-typeorm-driver';
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { DataSource } from 'typeorm';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      host: 'localhost',
      port: 5432,
      username: 'user',
      password: 'user',
      database: 'outbox',
      entities: [TypeOrmOutboxTransportEvent],
      migrations: [...OutboxTransportEventMigrations],
      migrationsRun: true,
    }),
    OutboxModule.registerAsync({
      imports: [TypeOrmModule.forFeature([TypeOrmOutboxTransportEvent])],
      useFactory: (dataSource: DataSource) => ({
        driverFactory: new TypeORMDatabaseDriverFactory(dataSource),
        events: [
          {
            name: 'OrderCreatedEvent',
            listeners: {
              retentionPeriod: 1000 * 60 * 60 * 24, // 24 hours
              maxExecutionTime: 1000 * 15,          // 15 seconds
              maxRetries: 5,                        // max retry attempts
            },
          },
        ],
        pollingInterval: 30_000,
        maxEventsPerPoll: 10,
      }),
      inject: [DataSource],
    }),
  ],
})
export class AppModule {}

Supported Databases

Database Real-time Support
PostgreSQL Polling only
MySQL Polling only

License

MIT