New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

notify-over-http

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notify-over-http

Listen and broadcast changes to id's across a clustered network simply over http.

latest
Source
npmnpm
Version
2.0.3
Version published
Maintainers
1
Created
Source

notify-over-http

GitHub code size in bytes GitHub package.json version GitHub

Listen and broadcast changes to id's across a clustered network simply over http.

Example

const http = require('http');
const createNotifyServer = require('notify-over-http');

// Create an instance of the notify server specifing all servers in the cluster
const notifyServer = createNotifyServer({
  servers: [{
    url: `https://localhost:8000/notify`,
    headers: {
      'x-secret': 'supersecret'
    }
  }]
});

// Broadcast to the network that ID 1 has changed every second
// -- Method 1 - Via the internal API
setInterval(() => {
  notifyServer.broadcast('1');
}, 1000);

// -- Method 2 - Via an HTTP post to any node
setInterval(() => {
  http.request('http://localhost:8000/notify?id=3', { method: 'POST' }).end();
}, 2000);


// Create an http server to handle the notification requests
http.createServer((request, response) => {
  // Only pass to the handler if the url starts with '/notify'
  // This path can be whatever you want
  if (request.url.startsWith('/notify')) {
    return notifyServer.handle(request, response);
  }

  // If it's not for the notifier, do whatever you want...
  response.writeHead(404);
  response.end('not found');
}).listen(8000);

// Watch for notifications
http.request('http://localhost:8000/notify?id=1&id=3', function (response) {
  response.on('data', data => console.log(data.toString()));
}).end();

Keywords

polling

FAQs

Package last updated on 21 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts