JSPM

@twaice/nestjs-kinesis-producer

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q29921F
  • License MIT

Kinesis Producer Library for NestJS

Package Exports

  • @twaice/nestjs-kinesis-producer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@twaice/nestjs-kinesis-producer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NestJS Kinesis Producer

Logo

Description

Kinesis Producer library for NestJS based on Node-Kinesis-Producer.

Installation

$ npm install @twaice/nestjs-kinesis-producer

Usage

  1. Register Module KinesisProducerModule.register for synchronous configuration or KinesisProducerModule.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 {}
  1. 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'
    }]);
  }
}