post-json-to-kafka

```bash yarn add post-json-to-kafka

Usage no npm install needed!

<script type="module">
  import postJsonToKafka from 'https://cdn.skypack.dev/post-json-to-kafka';
</script>

README

Publish list of object to kafka

XO code style

Install

yarn add post-json-to-kafka

# or

npm install --save post-json-to-kafka

Configuring

The location of kafka can be set by the environment variable:

KAFKA_URL=localhost:9092 # default

Example usage

const {sendToKafka} = require('post-json-to-kafka');

const exampleFunction = async () => {
  const somethingToAddInsideEachMessage = 'what you want string, object, list, number';
  const listOfJSON = [
    {key: 'value', key2: 'value2'},
    {key: 'value', something: 'value'}
  ];
  
   
  await sendToKafka('topic', somethingToAddInsideEachMessage, listOfJSON)
};

exampleFunction().then(() => {console.log('Everything is sent')});

Debugging

This package uses the debug package. You can configure it with environment variables:

DEBUG=post-json-to-kafka:debug # only debug messages
DEBUG=post-json-to-kafka:trace # only trace messages
DEBUG=post-json-to-kafka:*     # every messages