@sigmaott/nestjs-ksqldb-client
v1.0.1
Published
ksqldb-client for nestjs
Downloads
1
Readme
nestjs-ksqldb-client
This repo base on ksqldb-client and wrap decorator agenda job defined Agenda module for Nestjs
Agenda version is ^4.1.3
Installation
npm i @sigmaott/nestjs-ksqldb-client
Dependencies
Thank for @golevelup build the easy way to implement Dynamic Module and Discovery Module
Usage
1. Import KsqldbModule
:
Sync register:
import { KsqldbModule } from '@sigmaott/nestjs-ksqldb-client';
@Module({
imports: [KsqldbModule.forRoot(KsqldbModule, { host: 'http://', port: 8088})], // Same as configuring an agenda
providers: [...],
})
export class FooModule {}
Async register:
import { KsqldbModule } from '@sigmaott/nestjs-ksqldb-client';
@Module({
imports: [
KsqldbModule.forRootAsync(KsqldbModule, {
imports: [ConfigModule],
useFactory: async (config: ConfigService) => ({
...config.get('ksqldb'),
}),
inject: [ConfigService],
}),
],
providers: [...],
})
export class FooModule {}
2. Inject KsqldbModule
(AgendaService is a instance of Agenda):
import { Injectable } from '@nestjs/common';
import { KsqldbClientService } from '@sigmaott/nestjs-agenda;
@Injectable()
export class FooService {
constructor(private readonly ksqldbClient: KsqldbClientService) {
// schedule a job
}
private async testClient(job: any, done: any): Promise<void> {
ksqldbClient
}
}