https://github.com/balazs4/kifli
https://github.com/balazs4/kifli
mqtt nanoservice
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/balazs4/kifli
- Owner: balazs4
- Created: 2017-03-05T17:24:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-11T09:30:58.000Z (over 7 years ago)
- Last Synced: 2025-03-27T07:46:34.223Z (2 months ago)
- Topics: mqtt, nanoservice
- Language: JavaScript
- Size: 82 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# kifli
[](https://travis-ci.org/balazs4/kifli)
[](https://coveralls.io/github/balazs4/kifli?branch=master)
[](https://badge.fury.io/js/kifli)
[](https://david-dm.org/balazs4/kifli)
[](https://david-dm.org/balazs4/kifli?type=dev)
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fbalazs4%2Fkifli?ref=badge_shield)> nano library to handle messages sent throught MQTT protocol. It wraps the [mqtt.js](https://github.com/mqttjs/MQTT.js) module
## Motivation
I wanted to create a very lightweight message handler on the top of MQTT.
The main goal of this module is to use the power of the MQTT pub/sub model to create sort of **chainable** nanoservices without too much boilerplate.Highly inspired by [zeit/micro](https://github.com/zeit/micro) and [developit](https://github.com/developit).
## Usage
+ ``npm install --save kifli``
+ add the following script to your ``package.json``````json
{
"scripts": {
"start": "kifli handler.js --broker mqtt://localhost:1883 --topic '/sum' "
}
}
````+ create a ``handler.js`` file
````javascript
// handler.jsmodule.exports = ({ publish }) => async ({ topic, payload }) => {
await publish('/sum/result', {result: payload.a + payload.b});
};// the handler is automatically subscribed to the /sum topic
// assume that this topic always recevies two numbers (a and b) which shall be sumed
// the handler does its job and publish the result to a /sum/result topic
// imagine you have a handler which is listening to the /sum/result topic...````
## License
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fbalazs4%2Fkifli?ref=badge_large)