github metadata cache/mirror


A per-repo, always-up-to-date cache of Github's meta-data (like issues, PRs, and comments). Great for speeding up requests and avoiding running over GitHub's API limits.

Long-running services that want to frequently calculate/respond to metrics based on Github Issues, PRs, and comments. Metahub was created for Mary Poppins, a tool for helping to manage issues and PRs on populat Github repos.

For a more lightweight approach, you might want to look into:

var config = {
  // Github repo to watch
  target: {
    user: 'myname',
    repo: 'myrepo'
  // credentials for user who leaves comments, etc
  login: {
    username: 'myrobotname',
    password: 'supersecretpassword'
  // You may also use basic token authentication in place of username and password
  // by generating a personal access token at 
  //login: {
  //  username: 'yourTokenHere3098438ef098dsf709834',
  //  password: 'x-oauth-basic'
  // port to listen on,
  // and URL for Github to ping
  hook: {
    url: '',
    port: 1234
var meta = require('metahub')(config);
meta.on('issueReopened', function (data) {
  console.log('this issue was reopened: ' + data.number);

First, metahub makes a bajillion requests to Github to scrape all the data. Then, it launches an Express instance and uses Github's WebHooks API to stay up-to-date.

Uses promises (sorry, not sorry).

Metahub factory;

var makeMeta = require('metahub');
var config = {
  // etc...
var meta = makeMeta(config);

Useful if you want to extend Metahub:

var util = require('util');
var Metahub = require('metahub').Metahub;
var MyHub = function MyHub () {
  Metahub.apply(this, arguments);
util.inherits(MyHub, Metahub);

This property contains all of the issue info scraped from Github, organized by number.

// -> "The Issue Title"

This property contains all of the repo info scraped from Github:

// -> { "id": 1296269, "owner": { ... }, "name": "Hello-World", ... }

Starts the Github hook server, which listens to the port specified in the config.

Returns the commits for the specified PR.

Creates a comment for the specified issue/PR with the given moarkdown-formatted body.