MQTT input stream provides an easy wrapper around MQTT.js for mutator-io.
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[]
}
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)