1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const http_call_1 = tslib_1.__importDefault(require("http-call"));
|
5 | const GITHUB_API = 'https://api.github.com';
|
6 | class GitHubAPI {
|
7 | constructor(version, token) {
|
8 | this.version = version;
|
9 | this.token = token;
|
10 | }
|
11 | request(url, options = {}) {
|
12 | options.headers = Object.assign({ Authorization: `Token ${this.token}`, 'User-Agent': this.version }, options.headers);
|
13 | return http_call_1.default.get(`${GITHUB_API}${url}`, options);
|
14 | }
|
15 | getRepo(name) {
|
16 | return this.request(`/repos/${name}`).then((res) => res.body);
|
17 | }
|
18 | }
|
19 | exports.default = GitHubAPI;
|