@fullstackhouse/nestjs-outbox-typeorm-driver
v3.2.1
Published
This package provides a driver for the NestJS Outbox library that uses TypeORM to interact with the database.
Downloads
593
Readme
NestJS Outbox TypeORM Driver
TypeORM driver for @fullstackhouse/nestjs-outbox.
Features
- PostgreSQL & MySQL Support: Works with postgres and mysql drivers
Installation
npm install @fullstackhouse/nestjs-outbox-typeorm-driverQuick 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: {
expiresAtTTL: 1000 * 60 * 60 * 24, // 24 hours
maxExecutionTimeTTL: 1000 * 15, // 15 seconds
readyToRetryAfterTTL: 10000, // 10 seconds
},
},
],
retryEveryMilliseconds: 30_000,
maxOutboxTransportEventPerRetry: 10,
}),
inject: [DataSource],
}),
],
})
export class AppModule {}Supported Databases
| Database | Real-time Support | |------------|-------------------| | PostgreSQL | Polling only | | MySQL | Polling only |
License
MIT
