# kafka-connector

> A kafka connector built on top of kafkajs

Latest version **0.1.6** (published 2022-11-16) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install kafka-connector
pnpm add kafka-connector
yarn add kafka-connector
bun add kafka-connector
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2022-11-16 |
| First published | 2022-11-07 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tofeeq Ahmad |
| Maintainers | bsc-npm |

## Links

- npm: https://www.npmjs.com/package/kafka-connector
- npm.io page: https://npm.io/package/kafka-connector

## Dependencies (6)

- [rxjs](https://npm.io/package/rxjs.md) ^7.2.0
- [rimraf](https://npm.io/package/rimraf.md) ^3.0.2
- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.0
- [kafkajs](https://npm.io/package/kafkajs.md) ^2.2.2
- [inversify](https://npm.io/package/inversify.md) ^6.0.1
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 0.1.6 (latest) — 2022-11-16
- 0.1.5 — 2022-11-16
- 0.1.4 — 2022-11-15
- 0.1.3 — 2022-11-15
- 0.1.2 — 2022-11-14
- 0.1.1 — 2022-11-14
- 0.1.0 — 2022-11-14
- 0.0.9 — 2022-11-11
- 0.0.8 — 2022-11-11
- 0.0.7 — 2022-11-11
- 0.0.6 — 2022-11-10
- 0.0.5 — 2022-11-10
- 0.0.4 — 2022-11-10
- 0.0.1 — 2022-11-10
- 0.0.2 — 2022-11-07

## README

<p align="center">

</p>

## Description

[kafka-connector]A public TypeScript library for easy kafka producer and consumer.

## Installation

```bash
$ npm i kafka-connector
```

## How to use?
      
      Step 1 - Initilize KafkaManager, you can use custom host and port.
```bash      
    this.kafkaManager = await KafkaManager.create(); // 
    await this.kafkaManager.initilize({ host: 'localhost', 'port': 29092});
```   
     Step 2 - Consume existing topic
```bash      
    await this.kafkaManager.consume(
      { topic: 'customtopic' }, {
      eachMessage: async ({ topic, partition, message }) => {
        console.log({
          topic: topic.toString(),
          partition: partition.toString(),
          value: message.value.toString()
        })
      }
    });
```   
     Step 3 - Produce to existing or new topic
```bash      
        await kafkaManager.produce({
            topic: 'customtopic', messages: [
                {
                    key: 'create user',
                    value: 'Hi, New event happended!!'
                }
            ]
        })
```   
## Test

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov
```

## Stay in touch

- Author - [Tofeeq Ahmad]()

## License

Nest is [MIT licensed](LICENSE).

---
_Source: https://npm.io/package/kafka-connector · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
