1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/common/k8s-api/api-base.injectable.ts
Sebastian Malton 5c6402b60a
Make apiBase not an InjectionToken and make openNodeShellSession not special (#6774)
* Replace apiBaseInjectionToken with tokens for configuration instead

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Use new ordering to make openNodeShellSession non-special

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
2022-12-16 16:13:57 -05:00

34 lines
1.2 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 { apiPrefix } from "../vars";
import isDebuggingInjectable from "../vars/is-debugging.injectable";
import isDevelopmentInjectable from "../vars/is-development.injectable";
import { apiBaseHostHeaderInjectionToken, apiBaseServerAddressInjectionToken } from "./api-base-configs";
import createJsonApiInjectable from "./create-json-api.injectable";
const apiBaseInjectable = getInjectable({
id: "api-base",
instantiate: (di) => {
const createJsonApi = di.inject(createJsonApiInjectable);
const isDebugging = di.inject(isDebuggingInjectable);
const isDevelopment = di.inject(isDevelopmentInjectable);
const serverAddress = di.inject(apiBaseServerAddressInjectionToken);
const hostHeaderValue = di.inject(apiBaseHostHeaderInjectionToken);
return createJsonApi({
serverAddress,
apiBase: apiPrefix,
debug: isDevelopment || isDebugging,
}, {
headers: {
"Host": hostHeaderValue,
},
});
},
});
export default apiBaseInjectable;