@twaice/nestjs-kinesis-producer
v0.0.2
Published
Kinesis Producer Library for NestJS
Downloads
4
Readme
NestJS Kinesis Producer
Description
Kinesis Producer library for NestJS based on Node-Kinesis-Producer.
Installation
$ npm install @twaice/nestjs-kinesis-producer
Usage
- 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'
}]);
}
}