Files
angular__angular/tools/dashboard/functions/github/github-api.ts
T
Paul Gschwendtner c021e94fce chore(dashboard): http function to list pull requests with conflicts (#6675)
Introduces a new http trigger in the Dashboard functions that returns all Pull Requests with merge conflicts. This allows us to show a list of PRs with merge conflicts in the dashboard.

To ensure that the API calls are as fast as possible, the pull requests with conflicts are queried using Github's new GraphQL API.
2017-09-28 16:05:46 -07:00

23 lines
853 B
TypeScript

import {GraphQLClient} from 'graphql-request';
import {config} from 'firebase-functions';
import * as GithubApi from 'github';
/** API token for the Github repository. Required to set the github status on commits and PRs. */
const githubAccessToken = config().secret.github;
/** API Endpoint for the Github API v4 using GraphQL. */
const githubApiV4Endpoint = 'https://api.github.com/graphql';
/** Export the GitHub V3 API instance that is authenticated. */
export const githubApiV3 = new GithubApi();
/** Export the GraphQL client that can be used to query the Github API v4. */
export const githubApiV4 = new GraphQLClient(githubApiV4Endpoint, {
headers: {
Authorization: `Bearer ${githubAccessToken}`,
}
});
// Authenticate the Github API package with the user token.
githubApiV3.authenticate({type: 'token', token: githubAccessToken});