mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* 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>
34 lines
1.2 KiB
TypeScript
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;
|