UNPKG

708 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const http_call_1 = tslib_1.__importDefault(require("http-call"));
5const GITHUB_API = 'https://api.github.com';
6class 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}
19exports.default = GitHubAPI;