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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gith

v1.0.4

Published

gith[ooks] - a simple node server that responds to github post-receive events with meaningful data

Readme

gith

gith[ooks] - a simple node server that responds to github post-receive events with meaningful data

Getting Started

Install

Install the module with: npm install gith

Require

In your node application, require gith and create a gith server. You can specify a port now, or you can use the .listen( portNumber ) method later.

// create a gith server on port 9001
var gith = require('gith').create( 9001 );

Use

Pass an object of how you want to filter gith (if at all) and subscribe to an event.

gith({
  repo: 'danheberden/gith'
}).on( 'all', function( payload ) {
  console.log( 'Post-receive happened!' );
});

Hook

Be sure github.com is sending payload data to your server. From your repository root go to Admin > Service Hooks > WebHook URLs and add your server url, e.g., http://mycoolserver.com:9001.

Filtering

The object passed into gith() can utilize four parameters (repo, branch, file and tag). All of these can either be an exact match string, a regular expression or a function.

For example:

gith({
  repo: 'danheberden/gith',
  branch: /issue_(\d+)/
}).on( 'branch:add', function( payload ) {
  console.log( 'A branch matching /issue_(\d+)/ was added!' );
  console.log( 'The issue # is', payload.matches.branch[1] );
});

You can either omit the key that you don't want to filter (e.g., we would get every file and tag in the above example) or use * to specifiy that it's a wildcard.

Events

Events available are:

  • all - as long as the filtering passed, this will get fired
  • branch:add
  • branch:delete
  • file:add
  • file:modify
  • file:delete
  • file:all
  • tag:add
  • tag:delete

Payload

The github payload is very detailed, but can be a bit excessive.

This is the payload that gith gives you:

{
  original: the-original-github-payload,
  files: {
    all: [],
    added: [],
    deleted: [],
    modified: []
  },
  tag: tag, /* if a tagging operation */
  branch: branch, /* if working on a branch */
  repo: the-repo-name,
  sha: the-now-current-sha,
  time: when-it-was-pushed,
  urls: {
    head: current-sha
    branch: branch-url-if-available,
    tag: sha-url-of-tag-if-available,
    repo: repo-url,
    compare: compare-url
  },
  reset: did-the-head-get-reset,
  pusher: github-username-of-pusher,
  owner: github-username-of-repo-owner
}

gith()

The gith function returns a new Gith object that has all of the EventEmitter2 methods.

Additional gith Methods

On the gith server, there are three additional methods available:

gith.close()

This closes the gith server

gith.listen( port )

If you didn't pass in a port to .create() when you required gith, this will start the server on the specified port

gith.payload( github-style-payload )

You can broadcast a payload to the gith server manually.

License

Copyright (c) 2012 Dan Heberden Licensed under the MIT license.