Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/balazs4/kifli
https://github.com/balazs4/kifli
mqtt nanoservice
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/balazs4/kifli
- Owner: balazs4
- Created: 2017-03-05T17:24:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-11T09:30:58.000Z (over 6 years ago)
- Last Synced: 2024-10-04T18:41:48.808Z (about 1 month ago)
- Topics: mqtt, nanoservice
- Language: JavaScript
- Size: 82 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# kifli
[![Build Status](https://travis-ci.org/balazs4/kifli.svg?branch=master)](https://travis-ci.org/balazs4/kifli)
[![Coverage Status](https://coveralls.io/repos/github/balazs4/kifli/badge.svg?branch=master)](https://coveralls.io/github/balazs4/kifli?branch=master)
[![npm version](https://badge.fury.io/js/kifli.svg)](https://badge.fury.io/js/kifli)
[![dependencies Status](https://david-dm.org/balazs4/kifli/status.svg)](https://david-dm.org/balazs4/kifli)
[![devDependencies Status](https://david-dm.org/balazs4/kifli/dev-status.svg)](https://david-dm.org/balazs4/kifli?type=dev)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbalazs4%2Fkifli.svg?type=shield)](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
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbalazs4%2Fkifli.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbalazs4%2Fkifli?ref=badge_large)