Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/services/api/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type AxiosOptions = {

export interface BaseAPIParams {
singleClusterMode?: boolean;
proxyMeta?: boolean;
}

export class BaseYdbAPI extends AxiosWrapper {
Expand Down
4 changes: 3 additions & 1 deletion src/services/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ export class YdbEmbeddedAPI {
singleClusterMode,
csrfTokenGetter = () => undefined,
defaults = {},
proxyMeta = false,
}: {
webVersion?: boolean;
withCredentials?: boolean;
singleClusterMode?: boolean;
csrfTokenGetter?: () => string | undefined;
defaults?: AxiosRequestConfig;
proxyMeta?: boolean;
} = {}) {
const axiosParams: AxiosWrapperOptions = {config: {withCredentials, ...defaults}};
const baseApiParams = {singleClusterMode};
const baseApiParams = {singleClusterMode, proxyMeta};

this.auth = new AuthAPI(axiosParams, baseApiParams);
if (webVersion) {
Expand Down
15 changes: 13 additions & 2 deletions src/services/api/meta.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type {AxiosWrapperOptions} from '@gravity-ui/axios-wrapper';

import {metaBackend as META_BACKEND} from '../../store';
import type {MetaCapabilitiesResponse} from '../../types/api/capabilities';
import type {
Expand All @@ -8,11 +10,20 @@ import type {
} from '../../types/api/meta';
import {parseMetaTenants} from '../parsers/parseMetaTenants';

import type {AxiosOptions} from './base';
import type {AxiosOptions, BaseAPIParams} from './base';
import {BaseYdbAPI} from './base';

export class MetaAPI extends BaseYdbAPI {
getPath(path: string, _clusterName?: string) {
proxyMeta?: boolean;
constructor(axiosOptions?: AxiosWrapperOptions, {proxyMeta}: BaseAPIParams = {}) {
super(axiosOptions);

this.proxyMeta = proxyMeta;
}
getPath(path: string, clusterName?: string) {
if (this.proxyMeta && clusterName) {
return `${META_BACKEND}/proxy/cluster/${clusterName}${path}`;
}
return `${META_BACKEND ?? ''}${path}`;
}

Expand Down
Loading