1.1.5 • Published 9 months ago

parse-github-event v1.1.5

Weekly downloads
14
License
MIT
Repository
github
Last release
9 months ago

parse-github-event Build Status

Small library to parse Event Types from Github API response.

Feature

  • Parse event json and built message and html_url without addtional request
  • Create human-readable message like GitHub's timeline from event json

Installation

npm install parse-github-event

Usage

Response json object of GitHub Events API.

{
    "id": "2070416128",
    "type": "PullRequestEvent",
    "actor": {
        "id": 1062518,
        "login": "pivotal-brian-croom",
        "gravatar_id": "92d36bd6d9b53539fcec282452872710",
        "url": "https://api.github.com/users/pivotal-brian-croom",
        "avatar_url": "https://avatars.githubusercontent.com/u/1062518?"
    },
    "repo": {
        "id": 708684,
        "name": "pivotal/cedar",
        "url": "https://api.github.com/repos/pivotal/cedar"
    },
    "payload": {
        "action": "opened",
        "number": 231,
        "pull_request": {
            "url": "https://api.github.com/repos/pivotal/cedar/pulls/231",
            "body": "- Common code consolidated into CDROTestRunner and CDROTestIPhoneRunner\r\n- CDROTestIPhoneRunner subclasses CDROTestRunner\r\n[#67878220]\r\n\r\nThoughts?\r\n@idoru, @jeffh",
            "created_at": "2014-04-24T05:01:39Z",
            "updated_at": "2014-04-24T05:01:39Z",
    ...
}

Parse response

var parseGithubEvent = require("parse-github-event");
// responseJSON is come from https://developer.github.com/v3/activity/events/
var parsed = parseGithubEvent.parse(responseJSON);
/*
{
    text: 'opened issue on %%repository%%',
    data: { repository: 'pivotal/cedar' },
    html_url : 'https://github.com/pivotal/cedar/pull/231'
}
*/

Create message

It's bonus method.

var parseGithubEvent = require("parse-github-event");
var result = parseGithubEvent.compile(json);
// pivotal-brian-croom opened issue on pivotal/cedar

UseCase

Create one-line message and html_url from event response.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

Thanks for alindeman/github-timeline-widget.

Use these as a reference

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.2.0

9 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago