You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

kifli

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kifli

nanoservice for mqtt protocol (nano+mqtt=kifli)

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
4
100%
Maintainers
1
Weekly downloads
 
Created
Source

kifli

Build Status Coverage Status npm version dependencies Status devDependencies Status

nano library to handle messages sent throught MQTT protocol. It wraps the 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 and developit.

Usage

  • npm install --save kifli
  • add the following script to your package.json
{
  "scripts": {
    "start": "kifli handler.js --broker mqtt://localhost:1883 --topic '/sum' "
  }
}
  • create a handler.js file
// handler.js

module.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...

Keywords

mqtt

FAQs

Package last updated on 08 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts