Skip to content

sigmaott/nestjs-ksqldb-client

Repository files navigation

nestjs-ksqldb-client

This repo base on ksqldb-client for Nestjs

ksqldb-client version is ^1.0.5

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 ksqldb-client
  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 (KsqldbClientService is a instance of KsqldbClient):

import { Injectable } from '@nestjs/common';
import { KsqldbClientService } from '@sigmaott/nestjs-ksqldb-client;

@Injectable()
export class FooService {
  constructor(private readonly ksqldbClient: KsqldbClientService) {
    // schedule a job
  }

  private async testClient(job: any, done: any): Promise<void> {
    ksqldbClient
  }
}

About

ksqldb-client module for nestjs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published