An open API service indexing awesome lists of open source software.

https://github.com/jalorenz/nestjs-kafkajs-module

Importable module for Nest.js to use in Kafka.js in your application
https://github.com/jalorenz/nestjs-kafkajs-module

event kafka kafkajs module nestjs typescript

Last synced: 6 months ago
JSON representation

Importable module for Nest.js to use in Kafka.js in your application

Awesome Lists containing this project

README

          

# nestjs-kafkajs-module

Nest.js module for injecting Kafka.js producer and consumer in Nest.js application.

## Installation

```bash
npm install nestjs-kafkajs-module
```

## Usage

```typescript
import { KafkajsModule } from "nestjs-kafkajs-module";
import { KafkaConfig } from "kafkajs";

const config: KafkaConfig = {
clientId: "example",
brokers: ["localhost:9092"],
};

@Module({
imports: [
KafkajsModule.register(config, "exampleConsumerGroup"),
],
})
export class AppModule {}
```

```typescript
import { Injectable } from "@nestjs/common";
import { InjectConsumer, InjectProducer } from "nestjs-kafkajs-module";
import { Consumer, Producer } from "kafkajs";

@Injectable()
class ExampleService {
constructor(
@InjectConsumer() private readonly consumer: Consumer,
@InjectProducer() private readonly producer: Producer,
) {}
}
```

## Roadmap

- [x] Expose module to be able to inject Kafka.js producer and consumer in Nest.js application
- [x] Add CI
- [x] Publish to npm
- [ ] Add semantic versioning
- [ ] Build decorator for consumers