project setup

This commit is contained in:
Andrea Lamparelli 2022-12-06 18:10:30 +01:00
commit 05d156a5b0
39 changed files with 14823 additions and 0 deletions

View file

@ -0,0 +1,38 @@
import GitService from "@gb/service/git/git-service";
import { GitPullRequest } from "@gb/service/git/git.types";
import GitHubMapper from "@gb/service/git/github/github-mapper";
import OctokitFactory from "@gb/service/git/github/octokit-factory";
import { Octokit } from "@octokit/rest";
import { PullRequest } from "@octokit/webhooks-types";
export default class GitHubService implements GitService {
private octokit: Octokit;
private mapper: GitHubMapper;
constructor(token: string) {
this.octokit = OctokitFactory.getOctokit(token);
this.mapper = new GitHubMapper();
}
// READ
async getPullRequest(owner: string, repo: string, prNumber: number): Promise<GitPullRequest> {
const { data } = await this.octokit.rest.pulls.get({
owner: owner,
repo: repo,
pull_number: prNumber
});
return this.mapper.mapPullRequest(data as PullRequest);
}
// WRITE
// eslint-disable-next-line @typescript-eslint/no-unused-vars
createPullRequest(owner: string, repo: string, head: string, base: string, title: string, body: string, reviewers: string[]): Promise<void> {
// throw new Error("Method not implemented.");
// TODO implement
return Promise.resolve();
}
}