-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first version of swapping out clients * better reusability * working model * removing duplication * Update to checkCodeQLEnablement (#80) * Update to checkCodeQLEnablement Handling a 404 return from API call when no result are found. * Update checkCodeQLEnablement.ts Co-authored-by: Nick Liffen <nickliffen@github.com> * fixing linting * Update src/utils/clients/core.ts Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com> * updated final small changes to get refresh working Co-authored-by: Daniel Redman <43892709+djredman99@users.noreply.github.com> Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
- Loading branch information
1 parent
dc3af5e
commit a56edf7
Showing
20 changed files
with
98 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Octokit } from "@octokit/core"; | ||
import { createAppAuth } from "@octokit/auth-app"; | ||
import { env } from "process"; | ||
|
||
import { baseRestApiURL as baseUrl } from "../globals"; | ||
|
||
import { RateLimitOptions } from "../../../types/common"; | ||
|
||
import { retry } from "@octokit/plugin-retry"; | ||
import { throttling } from "@octokit/plugin-throttling"; | ||
import { paginateRest } from "@octokit/plugin-paginate-rest"; | ||
import { OctokitOptions } from "@octokit/core/dist-types/types"; | ||
|
||
export const client = async (): Promise<Octokit> => { | ||
const MyOctokit = Octokit.plugin(paginateRest, retry, throttling); | ||
const baseOctokitOptions = { | ||
baseUrl, | ||
request: { retries: 3 }, | ||
throttle: { | ||
onRateLimit: (options: RateLimitOptions) => { | ||
return options.request.retryCount <= 3; | ||
}, | ||
onAbuseLimit: () => { | ||
return true; | ||
}, | ||
}, | ||
} as OctokitOptions; | ||
|
||
if (env.GITHUB_API_TOKEN) { | ||
return new MyOctokit({ | ||
auth: env.GITHUB_API_TOKEN, | ||
...baseOctokitOptions, | ||
}); | ||
} else if (env.APP_ID && env.APP_PRIVATE_KEY && env.APP_INSTALLATION_ID) { | ||
return new MyOctokit({ | ||
authStrategy: createAppAuth, | ||
auth: { | ||
appId: env.APP_ID as string, | ||
privateKey: env.APP_PRIVATE_KEY as string, | ||
installationId: parseInt( | ||
env.APP_INSTALLATION_ID as string, | ||
10 | ||
) as number, | ||
}, | ||
...baseOctokitOptions, | ||
}); | ||
} else { | ||
throw new Error( | ||
"You have not specified a Personal Access Token or all the requried variables for a GitHub App. Please re-check the documentation" | ||
); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { graphQLClient } from "./graphql"; | ||
import { restClient } from "./rest"; | ||
import { client } from "./core"; | ||
import { auth } from "./auth"; | ||
|
||
export { graphQLClient, restClient, auth }; | ||
export { auth, client }; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters