Skip to content

Instantly share code, notes, and snippets.

@jaydp17
Created December 31, 2014 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaydp17/bf25dc5f9d158901e82c to your computer and use it in GitHub Desktop.
Save jaydp17/bf25dc5f9d158901e82c to your computer and use it in GitHub Desktop.
A simple server using mors
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