Socket.io module for Mono
Mono-io uses socket.io and socketio-jwt to handle sockets with authorization via JWT.
npm install --save mono-io
Then, in your configuration file of your Mono application (example: conf/application.js
):
module.exports = {
mono: {
modules: ['mono-io']
}
}
mono-io will use the io
property of your configuration (example: conf/development.js
):
module.exports = {
mono: {
io: {
// See options here: https://github.com/socketio/socket.io/blob/master/docs/API.md#new-serverhttpserver-options
}
}
}
In your modules files, you can access io
instance:
const { io } = require('mono-io')
io.on('connection', function (socket) {
console.log(socket)
})