# kafka-typescript-v2

> Interface to node-rdkafka in Typescript. Forked from CoNarrative simple wrapper

Latest version **1.0.0** (published 2019-05-01) · Apache 2.0 license · 0 weekly downloads

## Install

```sh
npm install kafka-typescript-v2
pnpm add kafka-typescript-v2
yarn add kafka-typescript-v2
bun add kafka-typescript-v2
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-05-01 |
| First published | 2019-05-01 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | arana3 / CoNarrative |
| Maintainers | arana156 |
| Keywords | kafka, typescript |

## Links

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

## Dependencies (1)

- [node-rdkafka](https://npm.io/package/node-rdkafka.md) ^2.6.1

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-05-01

## README

# kafka-typescript

Typescript wrapper for [node-rdkafka](https://github.com/Blizzard/node-rdkafka).

Intended to make it easier to quickly create topic consumers and producers for Apache Kafka.

Inspiration drawn from Kafka's Java API and Confluent.

## Usage

Start Zookeeper and Kafka:
```bash
confluent start
```

Producer:
```typescript
import {IProducerConfig, ProducerConfig, SimpleProducer} from "kafka-typescript"

const rdkafka = require("node-rdkafka")
const rdkafkaProducer = rdkafka.Producer

const producers: { [topic: string]: SimpleProducer } = {}

const createTopicProducer = async (topic: string, config: IProducerConfig) => {
  const prod = await new SimpleProducer().create(rdkafkaProducer, config)
                                         .connect()
  prod.setTopic(topic);
  producers[topic] = prod
  return prod
}

createTopicProducer("hello-world", new ProducerConfig("localhost", "9092"))
.then(x => {
  producers["hello-world"].send("1", new Buffer("hello"));
}).catch(err => console.error(err))
```

Consumer:
```typescript
import {ConsumerConfig, SimpleConsumer} from "kafka-typescript";

const rdkafka = require("node-rdkafka")
const rdkafkaConsumer = rdkafka.KafkaConsumer;

const consumerConfig = new ConsumerConfig("localhost", "9092", "hello-world-group");

const consumer = new SimpleConsumer()
  .create(rdkafkaConsumer, ["hello-world"], consumerConfig)
  .onMessage(({topic, key, value}) =>
    console.log("Rec'd", topic.toString(), key.toString(), value.toString()))
  .connect()
  
=> "Rec'd hello-world 1 hello"
```

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