npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pushinator

v1.6.3

Published

A simple server to push messages in realtime from your application to http clients, based on socket.io

Downloads

7

Readme

pushinator

A simple server to push messages in realtime from your application to http clients, based on socket.io

Installation

npm install pushinator

Example configuration

	module.exports = {
		// Path to pid file
	        pidfile: '/tmp/pushinator.pid',
		// Admin section
	        admin: {
			// Host or IP to listen
	                host: 0,
			// Port to listen
	                port: 9600,
	        },
		// Client section
	        client: {
			// Host or IP to listen
	                host: 0,
			// Port to listen
	                port: 9601,
			// socket.io transports available and usage order
	                socketIoTransports: ['websocket', 'flashsocket', 'xhr-polling', 'jsonp-polling', 'htmlfile'],
			// Use SSL on client port
	                useSSL: false,
			// Path to SSL private key file
	                sslKey: '/path/to/ssl.key',
			// Path to SSL certificate file
	                sslCert: '/path/to.crt',
	        },
		// Log section
	        log: {
			// Enable debug logging, can be true or false
	                debug: false,
			// Syslog configuration
	                syslog: {
				// Enable logging through syslog
	                        enable: true,
				// Syslog tag to use
	                        tag: 'pushinator',
				// Facility to use
	                        facility: 'LOG_DAEMON',
	                },
	        },
	}

Usage

In foreground

pushinator -c /path/to/configuration

As daemon

Pushinator can be run as daemon. It can be used as an init script and supports the following commands

start, restart, stop, status

If you want to run pushinator without config arguement, the configuration must be placed in /etc/pushinator.conf.

The following command starts pushinator as a daemon with config file located in /etc/pushinator/node1.conf

pushinator start -c /etc/pushinator/node1.conf

To stop it, use the following command

pushinator stop -c /etc/pushinator/node1.conf

Logging

By default, pushinator is logging to stdout if it's not started as a daemon. In daemon mode it's logging to syslog, if enabled. If syslog is not enabled, and pushinator is running as daemon, it's logging to /dev/null.

socket.io transports

You can specify the transports used by socket.io in the pushinator configuration. Order matters.

Admin connection

Through the admin connection, you can register new clients and send messages to them.

Registering a new user expects an userId and a hash. curl http://127.0.0.1:9600/user/register -d '{"userId":5,"hash":"xxx1234"}'

Sending a message to an user expects an userId and a message. curl http://127.0.0.1:9600/user/send -d '{"userId":5,"message":"example message"}'

Client connection

Before a socket.io client is able to receive messages from pushinator, it has to authenticate itself through the hash (which was set through the admin connection) and it's userId.

	var userId = 5;
	var hash = 'xx1234';

	var socket = io.connect('http://127.0.0.1:9601');
	socket.on('connect', function () {
		// authenticate
		socket.emit('auth', userId, hash);
	});

	socket.on('message', function (message) {
		// handle received message
		alert(message);
	});

For more thorough examples, look at the examples/ directory.