mutator-io-plugin-in-mqtt
v0.1.7
Published
Input stream plugin for mutator-io to interface with MQTT
Downloads
3
Maintainers
Readme
MQTT input stream
MQTT input stream provides an easy wrapper around MQTT.js for mutator-io.
Installation
npm i mutator-io-plugin-in-mqtt
The configuration required is exactly the same, with the except of a new keyword called topics
that will indicate which topics this instance should subscribe to.
import { IClientOptions } from 'mqtt/types'
interface Config extends IClientOptions {
topics: string[]
}
TLS support
This kind of security is supported just like it is in MQTT.js (though there aren't many examples around)
import * as MqttInputStream from 'mutator-io-plugin-in-mqtt'
const myInputStream = new MqttInputStream({
protocol: 'mqtts',
host: 'my-endpoint.iot.eu-central-1.amazonaws.com',
port: 8883,
key: fs.readFileSync('./certs/mqtt.key'),
cert: fs.readFileSync('./certs/mqtt.pem'),
ca: fs.readFileSync('./certs/mqtt_ca.pem'),
requestCert: true,
rejectUnauthorized: true,
topics: ['something/+/+/+/status/+/+/+']
} as MqttInputStream.Config)