diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz deleted file mode 100644 index 4d8e252..0000000 Binary files a/.yarn/install-state.gz and /dev/null differ diff --git a/src/actions/custom.ts b/src/actions/custom.ts index 3c7829b..c95d226 100644 --- a/src/actions/custom.ts +++ b/src/actions/custom.ts @@ -12,7 +12,7 @@ export type CreatePagerDutyServiceActionProps = { logger: LoggerService; }; -export const createPagerDutyServiceAction = (props : CreatePagerDutyServiceActionProps) => { +export const createPagerDutyServiceAction = (props? : CreatePagerDutyServiceActionProps) => { let loggerService: LoggerService; @@ -40,7 +40,7 @@ export const createPagerDutyServiceAction = (props : CreatePagerDutyServiceActio async handler(ctx) { try { loggerService = props?.logger ? props.logger : ctx.logger; - const configService = props?.config ?? props.config; + const configService = props?.config; const legacyConfig: Config = await loadBackendConfig({ logger: loggerService, diff --git a/src/auth/auth.ts b/src/auth/auth.ts index 5cb7f68..b9ac28a 100644 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -8,7 +8,7 @@ type Auth = { } export type LoadAuthConfigProps = { - config: RootConfigService; + config: RootConfigService | undefined; legacyConfig: Config; logger: LoggerService; } @@ -22,8 +22,7 @@ interface JsonObject { type JsonArray = JsonValue[]; let authPersistence: Auth; -let isLegacyConfig: boolean; -let _config: RootConfigService; +let _config: RootConfigService | undefined; let _legacyConfig: Config; let _logger: LoggerService; @@ -47,9 +46,6 @@ export async function getAuthToken(): Promise { export async function loadAuthConfig({config, legacyConfig, logger}: LoadAuthConfigProps) { try { - // check if we are using new backend system. Fallback to legacy config if not - isLegacyConfig = !config; - // set config and logger _config = config; _legacyConfig = legacyConfig; @@ -93,15 +89,16 @@ export async function loadAuthConfig({config, legacyConfig, logger}: LoadAuthCon } function readOptionalString(key: string) : string | undefined { - if (isLegacyConfig) { + if (!_config) { return _legacyConfig.getOptionalString(key); - } - + } + return _config.getOptionalString(key); + } function readOptionalObject(key: string): JsonValue | undefined { - if (isLegacyConfig) { + if (!_config) { return _legacyConfig.getOptional(key); } @@ -109,7 +106,7 @@ function readOptionalObject(key: string): JsonValue | undefined { } function readString(key: string) : string { - if (isLegacyConfig) { + if (!_config) { return _legacyConfig.getString(key); }