Kinesis Producer library for NestJS based on Node-Kinesis-Producer.
$ npm install @twaice/nestjs-kinesis-producer
- Register Module
KinesisProducerModule.register
for synchronous configuration orKinesisProducerModule.registerAsync
Asynchronous configuration.
import { HttpModule } from '@nestjs/common';
import { KinesisProducerModule } from '@twaice/nestjs-kinesis-producer';
@Module({
imports: [
KinesisProducerModule.registerAsync({
useFactory: (configService: ConfigService) => {
return {
streamName: configService.get<string>('streamName')
};
},
inject: [ConfigService],
}),
],
controllers: [SampleController],
providers: [SampleService],
exports: [SampleService],
})
export class SampleModule {}
- Use module in your service
import { KinesisProducerService } from '@twaice/nestjs-kinesis-producer';
@Injectable()
export class KinesisAggregatorPublisher {
constructor(private readonly kinesisPublisher: KinesisProducerService) {
}
async putDataIntoKinesis() {
await this.kinesisPublisher.getProducer().putRecords([{
Data: 'test-record'
}]);
}
}