socket.io-notify

A simple notification dispatcher written in nodeJS using socket.io

Usage no npm install needed!

<script type="module">
  import socketIoNotify from 'https://cdn.skypack.dev/socket.io-notify';
</script>

README

Socket.IO Notify

A simple notification dispatcher written in nodeJS using socket.io

How to use

$ cd socket.io-notify
$ npm install
$ node .

Sending notifications

$ curl --request POST 'http://localhost:3000/send' --header apisecret:NOTIFICATION_SECRET --data 'notification=notificationexample&channel=SOME_CHANNEL'

Client side


document.addEventListener("DOMContentLoaded", function(event) {
  var socket = io.connect('127.0.0.1:3000', {
    query: 'notificationKey=NOTIFICATION_KEY'
  });
  socket.on('NEW_NOTIFICATION', function (notification) {
    console.log(notification);
  });

  socket.emit('join', 'SOME_CHANNEL');
});