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

notifyit

v0.0.1

Published

Simple notification tool, designed to publish notifications.

Downloads

3

Readme

#NotifyIt

This is a simple PubSub tool which allows you to publish events via an HTTP POST interface, and subscribe to events via a socket.io connection.

##Pre-reqs To use this tool, you'll need to have node.js (v0.4 or greater) and npm installed. I've tested the tool on OSX and Linux, but it should work fine on Windows as well.

##Install

git clone git://github.com/sethmcl/notifyit.git
cd notifyit
npm install

Alternatively, install directly with npm:

npm install notifyit

##Usage

To start the server, run:

$ bin/notifyit [port]

You can optionally specify a port. If not port is specified, the default port of 2012 will be used.

##Publishing Events To publish an event, post to the /pub endpoint on the server. For example to publish an event called "new-data" on the "test" channel, you could POST something like this:

$ curl http://localhost:2012/pub/test/new-data -d "{\"name\":\"Seth\"}" -H "Content-Type:application/json" -v

By specifying the Content-Type, NotifyIt will attempt to parse the request body as JSON. If the parsing fails (due to malformed JSON), then the event will not be published and you will receive a 500 HTTP response.

If you do not specify a content type, NotifyIt will assume the data is simple text. Let's publish an event called "connect" on the "test" channel:

$ curl http://localhost:2012/pub/test/connect -d "name=Seth" -v

Try running these commands - you will see status output in the console where you are running the server.

##Subscribing to Events Subscribing to events is pretty straightforward. Include the socket.io client library on your page or node.js script, and then subscribe to events. Example:

var socket = io.connect('http://localhost:2012');
socket.on('test:new-data', function(e) {
  console.log( e.channel ); // Channel name, e.g., 'test'
  console.log( e.event );   // Event name, e.g., 'new-data'
  console.log( e.data );    // Data, e.g., 'name:Seth'. If event data was published as JSON, then this will be an object.
}

Alternatively, you can subscribe to the 'all' event to receive all events:

var socket = io.connect('http://localhost:2012');
socket.on('all', function(e) {
  console.log( e.channel ); // Channel name, e.g., 'test'
  console.log( e.event );   // Event name, e.g., 'new-data'
  console.log( e.data );    // Data, e.g., 'name:Seth'. If event data was published as JSON, then this will be an object.
}

##Sample App To see this in action, start the server:

$ bin/notifyit

Then open a browser and go to http://localhost:2012.

Finally, publish a sample event with a curl command:

$ curl http://localhost:2012/pub/test/connect -d "name=Seth"

You should see the event disaplayed in the browser.

##Running the Unit Tests

If you have not installed the nodeunit command before, please run these commands to build:

$ cd node_modules/nodeunit
$ sudo make install
$ cd ../../

To execute the tests, run this command from the repository root:

$ nodeunit tests/