# loopback-kafka-consumer-middleware

> Kafka consumer middleware for loopback

Latest version **1.0.2** (published 2017-12-14) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install loopback-kafka-consumer-middleware
pnpm add loopback-kafka-consumer-middleware
yarn add loopback-kafka-consumer-middleware
bun add loopback-kafka-consumer-middleware
```

## 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.2 |
| Published | 2017-12-14 |
| First published | 2017-12-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sébastien Krafft |
| Maintainers | skrafft |
| Keywords | loopback, kafka, middleware |

## Links

- npm: https://www.npmjs.com/package/loopback-kafka-consumer-middleware
- Repository: https://github.com/skrafft/loopback-kafka-consumer-middleware
- Homepage: https://github.com/skrafft/loopback-kafka-consumer-middleware#readme
- Issues: https://github.com/skrafft/loopback-kafka-consumer-middleware/issues
- npm.io page: https://npm.io/package/loopback-kafka-consumer-middleware

## Dependencies (1)

- [kafka-node](https://npm.io/package/kafka-node.md) ^2.3.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-12-14
- 1.0.1 — 2017-12-12
- 1.0.0 — 2017-12-12

## README

[![NPM](https://nodei.co/npm/loopback-kafka-consumer-middleware.png?compact=true)](https://nodei.co/npm/loopback-kafka-consumer-middleware/)
# Loopback kafka consumer middleware

This is a simple middleware listening for kafka events on a speficied topic.

INSTALL
=============

```bash
  npm install loopback-kafka-consumer-middleware --save
```

SERVER CONFIG
=============

Add the middleware to your *middleware.json*:

```json
{
  "loopback-kafka-consumer-middleware": {
    "params": {
      "consumerHandler": "./kafkaEventHandler"
    }
  }
}
```

HANDLER
=============

You need to define an event handler (in the previous example config, kafkaEventHandler.js) with the following structure in the loopback server directory.

```javascript
'use strict';

module.exports = {
  onMessage: function(message) {
    console.log('Msg: ' + JSON.stringify(message));
  },
  onError: function(err) {
    console.log(err);
  },
  onOffsetOutOfRange: function(err) {
    console.log(err);
  },
};
```

CONNEXIONS
=============

To be able to connect to your kafka host or zookeeper host and listen for events in the topic, you have to set the KAFKA_URL and KAFKA_TOPIC env variables

```bash
export KAFKA_URL=192.168.99.100:2181
export KAFKA_TOPIC=node-test
```

LICENSE
=============
[Apache-2.0] (LICENSE)

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