MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / createOctokitFromToken

Function createOctokitFromToken

packages/backend/src/github.ts:103–116  ·  view source on GitHub ↗
({ token, url }: { token?: string, url?: string })

Source from the content-addressed store, hash-verified

101}
102
103export const createOctokitFromToken = async ({ token, url }: { token?: string, url?: string }): Promise<{ octokit: Octokit, isAuthenticated: boolean }> => {
104 const isGitHubCloud = url ? new URL(url).hostname === GITHUB_CLOUD_HOSTNAME : true;
105 const octokit = new Octokit({
106 auth: token,
107 ...(url && !isGitHubCloud ? {
108 baseUrl: `${url}/api/v3`
109 } : {}),
110 });
111
112 return {
113 octokit,
114 isAuthenticated: !!token,
115 };
116}
117
118/**
119 * Helper function to get an authenticated Octokit instance using GitHub App if available,

Callers 4

getOctokitWithGithubAppFunction · 0.85
getGitHubReposFromConfigFunction · 0.85
runJobMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected