Skip to content

love-lena/fastify-mqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastify-mqtt

NPM version js-standard-style

Fastify MQTT plugin; shares the same MQTT connection in every part of your server.

Wrapper around mqtt

Install

npm i fastify-mqtt

Usage

Add it to your project with register and you are done!

const fastify = require('fastify')()

fastify.register(require('fastify-mqtt'), {  
  host: 'http://mybroker:port'
  //Add more options here
})

fastify.get('/user/:id', function (req, reply) {
  this.mqtt.publish('my/topic', 'user id requested')

  reply.send()
})

fastify.listen(3000, err => {
  if (err) throw err
})

License

Licensed under MIT.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published