New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nest-kinesis-producer

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nest-kinesis-producer

Efficient Node Kinesis Producer Based on Kevin Deng's AWS Big Data Blog

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
83
decreased by-53.63%
Maintainers
1
Weekly downloads
 
Created
Source

Kinesis Logo

Description

An effficient Nest.js Kinesis Producer based on Kevin Deng's blog piece

Installation

$ npm install nest-kinesis-producer

Adding the Global Module

Add the Kinesis Producer to your App Module imports. It will register globally.

Syncronously:
import { AppService } from './app.service';
import { Module } from '@nestjs/common';

@Module({
  imports: [KinesisProducerModule.forRoot(new Kinesis())],
  providers: [AppService],
})
export class AppModule {}
Asyncronously:
import { AppService } from './app.service';
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';

@Module({
  imports: [
      KinesisProducerModule.forRootAsync({
        useFactory: (cfg: ConfigService) => new Kinesis({credentials: cfg.getCreds()}),
        inject: [ConfigService],
        imports: [ConfigModule],
      }),
    ),
  ],
  providers: [AppService],
})
export class AppModule {}

Use the Publisher

import { hash } from 'crypto';
import { RetryingBatchKinesisPublisher } from "nest-kinesis-producer";


export class AppService {
  constructor(private readonly kinesisPublisher: RetryingBatchKinesisPublisher){}

  public async sendToKinesis(messages: string[]): Promise<void> {
    const events = messages.map((x) => {
      return {
        PartitionKey: this.getPartitionKey(x),
        Data: x
      };
    });
    await this.kinesisPublisher.putRecords('fakeStreamName', events);
  }

  public getPartitionKey(mesage: string): string {
    ...
  }
}

VSCode debug testing

`launch.json

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "name": "vscode-jest-tests",
      "request": "launch",
      "args": ["--runInBand"],
      "cwd": "${workspaceFolder}",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "disableOptimisticBPs": true,
      "program": "${workspaceFolder}/node_modules/jest/bin/jest",
      "outputCapture": "std",
      "skipFiles": [
        "${workspaceFolder}/node_modules/**/*.js",
        "${workspaceFolder}/lib/**/*.js",
        "<node_internals>/**/*.js"
      ]
    }
  ]
}

Support

Pull requests are welcome. Please remember that commits must be made using Angular conventional-changelog

Stay in touch

License

Nest-Kinesis-Producer is MIT licensed.

Keywords

FAQs

Package last updated on 01 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc