cycoder-server

Socket server with storage redis or nats

Usage no npm install needed!

<script type="module">
  import cycoderServer from 'https://cdn.skypack.dev/cycoder-server';
</script>

README

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')