diff --git a/server/src/git/github.ts b/server/src/git/github.ts index e9e68ec1..5dbee1b2 100644 --- a/server/src/git/github.ts +++ b/server/src/git/github.ts @@ -12,10 +12,16 @@ import { RequestError } from '@octokit/types'; export class GithubApi extends Repo { private octokit: any; - constructor(token: string) { + constructor(baseUrl: string, token: string) { super("github"); + + if (baseUrl === '') { + baseUrl = 'https://api.github.com'; + } + this.octokit = new Octokit({ - auth: token + auth: token, + baseUrl: baseUrl, }); } diff --git a/server/src/git/repo.test.ts b/server/src/git/repo.test.ts index 012d42db..ca02759a 100644 --- a/server/src/git/repo.test.ts +++ b/server/src/git/repo.test.ts @@ -6,7 +6,7 @@ import { GiteaApi } from './gitea'; describe('GithubApi', () => { it('should load config', () => { - const github = new GithubApi("token"); + const github = new GithubApi('', "token"); expect(github).toBeTruthy(); }); }); diff --git a/server/src/kubero.ts b/server/src/kubero.ts index c623ebcd..35655e7e 100644 --- a/server/src/kubero.ts +++ b/server/src/kubero.ts @@ -80,7 +80,7 @@ export class Kubero { this.giteaApi = new GiteaApi(process.env.GITEA_BASEURL as string, process.env.GITEA_PERSONAL_ACCESS_TOKEN as string); this.gogsApi = new GogsApi(process.env.GOGS_BASEURL as string, process.env.GOGS_PERSONAL_ACCESS_TOKEN as string); - this.githubApi = new GithubApi(process.env.GITHUB_PERSONAL_ACCESS_TOKEN as string); + this.githubApi = new GithubApi(process.env.GITHUB_BASEURL as string, process.env.GITHUB_PERSONAL_ACCESS_TOKEN as string); this.gitlabApi = new GitlabApi(process.env.GITLAB_BASEURL as string, process.env.GITLAB_PERSONAL_ACCESS_TOKEN as string); this.bitbucketApi = new BitbucketApi(process.env.BITBUCKET_USERNAME as string, process.env.BITBUCKET_APP_PASSWORD as string); diff --git a/server/src/modules/repositories.ts b/server/src/modules/repositories.ts index f1f90b92..641238ce 100644 --- a/server/src/modules/repositories.ts +++ b/server/src/modules/repositories.ts @@ -16,7 +16,7 @@ export class Repositories { constructor() { this.giteaApi = new GiteaApi(process.env.GITEA_BASEURL as string, process.env.GITEA_PERSONAL_ACCESS_TOKEN as string); this.gogsApi = new GogsApi(process.env.GOGS_BASEURL as string, process.env.GOGS_PERSONAL_ACCESS_TOKEN as string); - this.githubApi = new GithubApi(process.env.GITHUB_PERSONAL_ACCESS_TOKEN as string); + this.githubApi = new GithubApi(process.env.GITHUB_BASEURL as string, process.env.GITHUB_PERSONAL_ACCESS_TOKEN as string); this.gitlabApi = new GitlabApi(process.env.GITLAB_BASEURL as string, process.env.GITLAB_PERSONAL_ACCESS_TOKEN as string); this.bitbucketApi = new BitbucketApi(process.env.BITBUCKET_USERNAME as string, process.env.BITBUCKET_APP_PASSWORD as string); }