renovate/lib/util/http/bitbucket-server.ts
MaronHatoum b121deb969
refactor(util/http): move interfaces from index.ts to types.ts (#14335)
* refactor:util/http move interfaces and types from index.ts to types.ts

* refactor:reorder imports

* refactor:move HttpError from type.ts to index.ts

* refactor:change imports after moving HttpError from type.ts to index.ts

* refactor:revert white spaces

* refactor:revert moving httpError from types.ts to index.ts

* refactor: moving httpError from types.ts to index.ts

* refactor: change import

* refactor: change import

* refactor: change import

* refactor: fix circular dependencies (lint build)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2022-02-24 08:50:17 +00:00

31 lines
785 B
TypeScript

import { PlatformId } from '../../constants';
import { resolveBaseUrl } from '../url';
import type { HttpOptions, HttpResponse, InternalHttpOptions } from './types';
import { Http } from '.';
let baseUrl: string;
export const setBaseUrl = (url: string): void => {
baseUrl = url;
};
export class BitbucketServerHttp extends Http {
constructor(options?: HttpOptions) {
super(PlatformId.BitbucketServer, options);
}
protected override request<T>(
path: string,
options?: InternalHttpOptions
): Promise<HttpResponse<T>> {
const url = resolveBaseUrl(baseUrl, path);
const opts = {
baseUrl,
...options,
};
opts.headers = {
...opts.headers,
'X-Atlassian-Token': 'no-check',
};
return super.request<T>(url, opts);
}
}