1.0.5 • Published 3 years ago

cycoder-server v1.0.5

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

System Requirements

The following are required to function properly.

  • Node 10.0+
  • Redis 4.0+
  • Nats 2.0+

The system used

Installation

$ npm install cycoder-server

How to use

The following example attaches socket.io to a plain Node.JS HTTP server listening on port 3000

Simply code:

const ecosystem = require('cycoder-server').createServer({
    app: {
        id: '...', // set with uuid v4
        secret: '...'
    }
});

ecosystem.listen(3000);

Custom channel

Simply code:

ecosystem.channel({
    join: (socket, channel) => {},
    leave: (socket, channel, reason) => {}
});

How to server SocketIO and HTTP

Simply code:

echosystem.listen(3000).then(({ io, http }) => {
    // Code here
});

Or

const { io, http } = echosystem.listen(3000);

Multiple namespaces

Simply code:

ecosystem.of(/^\/dynamic-\d+$/)

Or

ecosystem.of('/dynamic-101')