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

Function createBitbucketCloudClient

packages/backend/src/bitbucket.ts:136–167  ·  view source on GitHub ↗
(user: string | undefined, token: string | undefined)

Source from the content-addressed store, hash-verified

134}
135
136export function createBitbucketCloudClient(user: string | undefined, token: string | undefined): BitbucketClient {
137 const authorizationString =
138 token
139 ? (!user || user === "x-token-auth")
140 ? `Bearer ${token}`
141 : `Basic ${Buffer.from(`${user}:${token}`).toString('base64')}`
142 : undefined;
143
144 const clientOptions: ClientOptions = {
145 baseUrl: BITBUCKET_CLOUD_API,
146 headers: {
147 Accept: "application/json",
148 ...(authorizationString ? { Authorization: authorizationString } : {}),
149 },
150 };
151
152 const apiClient = createBitbucketCloudClientBase(clientOptions);
153 apiClient.use(throwOnHttpError);
154 var client: BitbucketClient = {
155 deploymentType: BITBUCKET_CLOUD,
156 token: token,
157 apiClient: apiClient,
158 baseUrl: BITBUCKET_CLOUD_API,
159 gitUrl: BITBUCKET_CLOUD_GIT,
160 getReposForWorkspace: cloudGetReposForWorkspace,
161 getReposForProjects: cloudGetReposForProjects,
162 getRepos: cloudGetRepos,
163 shouldExcludeRepo: cloudShouldExcludeRepo,
164 }
165
166 return client;
167}
168
169/**
170* We need to do `V extends CloudGetRequestPath` since we will need to call `apiClient.GET(url, ...)`, which

Callers 3

runJobMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected