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

metahub

v0.6.2

Published

github metadata cache/mirror

Downloads

58

Readme

metahub

Build Status

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.

What is it good for?

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:

Usage

var config = {
  // Github repo to watch
  // https://github.com/myname/myrepo
  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 
  // https://github.com/settings/applications 
  
  //login: {
  //  username: 'yourTokenHere3098438ef098dsf709834',
  //  password: 'x-oauth-basic'
  //},

  // port to listen on,
  // and URL for Github to ping
  hook: {
    url: 'http://example.com:1234',
    port: 1234
  }
};

var meta = require('metahub')(config);

meta.on('issueReopened', function (data) {
  console.log('this issue was reopened: ' + data.number);
});

meta.start();

How does it work?

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.

API

Uses promises (sorry, not sorry).

makeMeta(config)

Metahub factory;

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

Metahub

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);

meta.issues

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

console.log(meta.issues[1347].title);
// -> "The Issue Title"

meta.repo

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

console.log(meta.repo);
// -> { "id": 1296269, "owner": { ... }, "name": "Hello-World", ... }

meta.start()

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


meta.getCommits(number)

Returns the commits for the specified PR.

meta.createComment(number, body)

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

License

MIT