1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/k8s/api-base.injectable.ts
Sebastian Malton a51a4e75f2 Remove all global uses of AppEventBus
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2022-07-20 09:46:54 -04:00

32 lines
1.0 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { apiBaseInjectionToken } from "../../common/k8s-api/api-base";
import { JsonApi } from "../../common/k8s-api/json-api";
import { apiPrefix } from "../../common/vars";
import isDebuggingInjectable from "../../common/vars/is-debugging.injectable";
import isDevelopmentInjectable from "../../common/vars/is-development.injectable";
const apiBaseInjectable = getInjectable({
id: "api-base",
instantiate: (di) => {
const isDevelopment = di.inject(isDevelopmentInjectable);
const isDebugging= di.inject(isDebuggingInjectable);
return new JsonApi({
serverAddress: `http://127.0.0.1:${window.location.port}`,
apiBase: apiPrefix,
debug: isDevelopment || isDebugging,
}, {
headers: {
"Host": window.location.host,
},
});
},
injectionToken: apiBaseInjectionToken,
});
export default apiBaseInjectable;