Created
December 31, 2014 08:19
-
-
Save jaydp17/bf25dc5f9d158901e82c to your computer and use it in GitHub Desktop.
A simple server using mors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mors = require('mors'), | |
mosca = require('mosca'), | |
app = mors(); | |
app.all('*', function (req, res, next) { | |
res.topic(req.topic).publish(req.payload); | |
}); | |
var ascoltatore = { | |
//using ascoltatore | |
type: 'mongo', | |
url: 'mongodb://localhost:27017/mqtt', | |
pubsubCollection: 'ascoltatori', | |
mongo: {} | |
}; | |
var moscaSettings = { | |
port: 3000, | |
backend: ascoltatore, | |
persistence: { | |
factory: mosca.persistence.Mongo, | |
url: 'mongodb://localhost:27017/mqtt' | |
} | |
}; | |
app.listen(moscaSettings, function (err, server) { | |
console.log('Mors/Mosca server started on ' + server.opts.port); | |
console.log('================================'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment