@@ -37,12 +37,12 @@ function createReadOnlyDynamic<T extends object>(instance: T): T & { [key: strin
3737 * Caches items for CACHE_TTL_MILLIS milliseconds, so we don't get items more than once.
3838 */
3939class LazyConfig {
40- private _cache = new Map < string , ConfigValue > ( ) ;
40+ private readonly _cache = new Map < string , ConfigValue > ( ) ;
4141 private ttl : number = Date . now ( ) + LazyConfig . CACHE_TTL_MILLIS ;
4242 static readonly CACHE_TTL_MILLIS : number = 300 * 1000 ;
4343
44- private static toUrl = ( value : string ) : URL => new URL ( value ) ;
45- private static toBoolean = ( value : string ) : boolean | undefined => {
44+ private static readonly toUrl = ( value : string ) : URL => new URL ( value ) ;
45+ private static readonly toBoolean = ( value : string ) : boolean | undefined => {
4646 const lower = value . toLowerCase ( ) ;
4747 if ( lower === "true" ) return true ;
4848 if ( lower === "false" ) return false ;
@@ -58,7 +58,7 @@ class LazyConfig {
5858 IS_APIM_AUTH_ENABLED : LazyConfig . toBoolean ,
5959 MAX_SESSION_AGE_MINUTES : ( value : string ) => {
6060 const num = Number ( value ) ;
61- if ( ! isNaN ( num ) ) return num ;
61+ if ( ! Number . isNaN ( num ) ) return num ;
6262 return undefined ;
6363 } ,
6464 } ;
@@ -73,20 +73,20 @@ class LazyConfig {
7373 result = undefined ;
7474 } else {
7575 const converter = LazyConfig . converters [ key ] ;
76- if ( ! converter ) {
77- result = value . trim ( ) ;
78- } else {
76+ if ( converter ) {
7977 try {
8078 result = converter ( value . trim ( ) ) ;
8179 } catch ( error ) {
82- log . warn ( { context : { key, value } , error } , "Config item type coercion failed" ) ;
80+ log . warn ( { context : { key } , error } , "Config item type coercion failed" ) ;
8381 result = undefined ;
8482 }
83+ } else {
84+ result = value . trim ( ) ;
8585 }
8686 }
8787
8888 if ( result === undefined ) {
89- log . error ( { context : { key, value } } , "Unable to get config item" ) ;
89+ log . error ( { context : { key } } , "Unable to get config item" ) ;
9090 throw new ConfigError ( `Unable to get config item ${ key } ` ) ;
9191 }
9292 return result ;
0 commit comments