1.2.6 • Published 6 years ago

typed-github-api v1.2.6

Weekly downloads
206
License
-
Repository
-
Last release
6 years ago

Typed GitHub API

This is another client for GitHub API, this one written in Typescript. It includes support for WebHooks using Express.

Example usage

This is how to set up a Web hook to receive notifications for issues being changed.

const bodyParser = require("body-parser");
import * as express from "express";
import * as gitHubApi from "typed-github-api";
import GitHubApi from "typed-github-api";
import { RequestWithRawBody } from "typed-github-api";

const app = express();
const gitHub = new GitHubApi({ userAgent: "My Client/1.0.0", oAuthToken: process.env.gitHubAccessToken });
const issueWebHook = new gitHubApi.IssueWebHook(process.env.gitHubWebHookSecret, gitHub);

// Configure app to let us get the data from a POST
app.use(bodyParser.json({
  verify: function (req: RequestWithRawBody, _res: express.Response, buf: Uint8Array, _encoding: string) {
    req.rawBody = buf;
  },
}));

app.use("/webhooks/github/issue", issueWebHook.router);

issueWebHook.registerAsyncHandler(
  async function (data: gitHubApi.IssueWebHookData) {
    const issue = data.issue;
    console.log(`Issue #${issue.number} created at ${issue.created} and closed at ${issue.closed}`);
  });

app.set("port", process.env.PORT || 8080);

app.listen(app.get("port"));
1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.29

7 years ago

1.1.28

7 years ago

1.1.27

7 years ago

1.1.26

7 years ago

1.1.25

7 years ago

1.1.24

7 years ago

1.1.23

7 years ago

1.1.22

7 years ago

1.1.21

7 years ago

1.1.20

7 years ago

1.1.19

7 years ago

1.1.18

7 years ago

1.1.17

7 years ago

1.1.16

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago