# metahub

> github metadata cache/mirror

Latest version **0.6.2** (published 2014-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install metahub
pnpm add metahub
yarn add metahub
bun add metahub
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.2 |
| Published | 2014-07-28 |
| First published | 2013-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+9 in 2 direct dependencies) |
| Install scripts | no |
| Author | Brian Ford |
| Maintainers | btford |
| Keywords | github, api, metadata, scrape |

## Links

- npm: https://www.npmjs.com/package/metahub
- npm.io page: https://npm.io/package/metahub

## Dependencies (4)

- [q](https://npm.io/package/q.md) ~0.9.6
- [github](https://npm.io/package/github.md) ~0.1.10
- [lodash](https://npm.io/package/lodash.md) ~1.3.1
- [express](https://npm.io/package/express.md) ~3.3.4

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.6.2 (latest) — 2014-07-28
- 0.6.1 — 2014-07-25
- 0.6.0 — 2014-07-25
- 0.5.0 — 2014-03-31
- 0.4.1 — 2014-02-10
- 0.4.0 — 2014-02-10
- 0.3.2 — 2014-02-05
- 0.3.1 — 2014-02-05
- 0.3.0 — 2014-02-04
- 0.2.1 — 2014-01-02
- 0.2.0 — 2013-12-09
- 0.1.0 — 2013-12-06
- 0.0.0 — 2013-09-03

## README

# metahub

[![Build Status](https://travis-ci.org/btford/metahub.svg)](https://travis-ci.org/btford/metahub)


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](https://github.com/btford/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:

* [`node-github`](https://github.com/ajaxorg/node-github)

## 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](http://developer.github.com/v3/issues/#get-a-single-issue), 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](http://developer.github.com/v3/repos/#get):

```
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

---
_Source: https://npm.io/package/metahub · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
