import type { Config , Objectype , Production } from './config.interface' ; const util = { isObject < T > ( value ) { return value !== null && typeof value === 'object' && ! Array . isArray ( value ) ; } , merge < T extends Objectype , U extends Objectype > ( target , source ) { for ( const key of Object . keys ( source ) ) { const targetValue = target [ key ] ; const sourceValue = source [ key ] ; if ( this . isObject ( targetValue ) && this . isObject ( sourceValue ) ) { Object . assign ( sourceValue , this . merge ( targetValue , sourceValue ) ) ; } } return { ... target , ... source } ; } , } ; export const configuration = async ( ) : Promise < Config > => { const { config } = await import ( './envs/default' ) ; const { config : environment } = < { config : Production ; } > await import ( `./envs/${ process . env . NODE_ENV || 'development' }` ) ; return util . merge ( config , environment ) ; } ;