@xnestjs/kafka
v1.12.3
Published
NestJS extension library for Kafka
Readme
@xnestjs/kafka
NestJS extension library for Apache Kafka
Install
npm install @xnestjs/kafka
# or using yarn
yarn add @xnestjs/kafkaUsage
Register sync
An example of nestjs module that import the @xnestjs/kafka
// module.ts
import { Module } from '@nestjs/common';
import { KafkaModule } from '@xnestjs/kafka';
@Module({
imports: [
KafkaModule.forRoot({
useValue: {
brokers: ['localhost'],
},
}),
],
})
export class MyModule {}Register async
An example of nestjs module that import the @xnestjs/kafka async
// module.ts
import { Module } from '@nestjs/common';
import { KafkaModule } from '@xnestjs/kafka';
@Module({
imports: [
KafkaModule.forRootAsync({
inject: [ConfigModule],
useFactory: (config: ConfigService) => ({
brokers: config.get('KAFKA_BROKERS'),
}),
}),
],
})
export class MyModule {}Environment Variables
The library supports configuration through environment variables. Environment variables below is accepted. All environment variables starts with prefix (KAFKA_). This can be configured while registering the module.
