Skip to content

Commit b139eb5

Browse files
feat: create Api directly with YdbEmbeddedAPI class (#1998)
1 parent dde82b0 commit b139eb5

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/lib.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export {AsideNavigation} from './containers/AsideNavigation/AsideNavigation';
99
export {configureStore, rootReducer} from './store';
1010
export {default as appRoutes} from './routes';
1111

12-
export {createApi, YdbEmbeddedAPI} from './services/api';
12+
export {YdbEmbeddedAPI} from './services/api';
1313
export {settingsManager} from './services/settings';
1414
export {getUserSettings} from './containers/UserSettings/settings';
1515
export {setSettingValue, getSettingValue} from './store/reducers/settings/settings';

src/services/api/index.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export class YdbEmbeddedAPI {
2525
meta?: MetaAPI;
2626
codeAssist?: CodeAssistAPI;
2727

28-
constructor({config, webVersion}: {config: AxiosRequestConfig; webVersion?: boolean}) {
28+
constructor({webVersion = false, withCredentials = false} = {}) {
29+
const config: AxiosRequestConfig = {withCredentials};
30+
2931
this.auth = new AuthAPI({config});
3032
if (webVersion) {
3133
this.meta = new MetaAPI({config});
@@ -41,9 +43,3 @@ export class YdbEmbeddedAPI {
4143
this.viewer = new ViewerAPI({config});
4244
}
4345
}
44-
45-
export function createApi({webVersion = false, withCredentials = false} = {}) {
46-
const config: AxiosRequestConfig = {withCredentials};
47-
const api = new YdbEmbeddedAPI({config, webVersion});
48-
return api;
49-
}

src/store/configureStore.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {History} from 'history';
44
import {createBrowserHistory} from 'history';
55
import {listenForHistoryChange} from 'redux-location-state';
66

7-
import {createApi} from '../services/api';
7+
import {YdbEmbeddedAPI} from '../services/api';
88

99
import {getUrlData} from './getUrlData';
1010
import rootReducer from './reducers';
@@ -57,7 +57,7 @@ const isSingleClusterMode = `${metaBackend}` === 'undefined';
5757
export function configureStore({
5858
aRootReducer = rootReducer,
5959
singleClusterMode = isSingleClusterMode,
60-
api = createApi({webVersion, withCredentials: !customBackend}),
60+
api = new YdbEmbeddedAPI({webVersion, withCredentials: !customBackend}),
6161
} = {}) {
6262
({backend, basename, clusterName} = getUrlData({
6363
href: window.location.href,

0 commit comments

Comments
 (0)