feat(aio): make githubToken mandatory for GithubApi

This commit is contained in:
Georgios Kalpakas
2017-02-27 22:40:13 +02:00
committed by Chuck Jazdzewski
parent c5644e5a0d
commit 37348989f0
5 changed files with 26 additions and 33 deletions

View File

@ -18,16 +18,14 @@ export class GithubApi {
protected requestHeaders: {[key: string]: string};
// Constructor
constructor(protected repoSlug: string, githubToken?: string) {
constructor(protected repoSlug: string, githubToken: string) {
assertNotMissingOrEmpty('repoSlug', repoSlug);
if (!githubToken) {
console.warn('No GitHub access-token specified. Requests will be unauthenticated.');
}
assertNotMissingOrEmpty('githubToken', githubToken);
this.requestHeaders = {'User-Agent': `Node/${process.versions.node}`};
if (githubToken) {
this.requestHeaders.Authorization = `token ${githubToken}`;
}
this.requestHeaders = {
'Authorization': `token ${githubToken}`,
'User-Agent': `Node/${process.versions.node}`,
};
}
// Methods - Public