import NodeCache from 'node-cache' ; class PokeAPIOptions { default protocol ? : 'https' | 'http' ; default hostName ? : string ; default versionPath ? : string ; default offset ? : number ; default limit ? : number ; default timeout ? : number ; default cacheLimit ? : number ; /** The version path of the API (e.g. '/api/v2/') */ cache ? : NodeCache ; constructor ( config = { } , cache ) { this . protocol = 'https' ; this . hostName = '://pokeapi.co' ; this . versionPath = '/api/v2/' ; this . offset = 0 ; this . limit = 100000 ; this . timeout = 10 * 1000 ; this . cacheLimit = 1000000 * 1000 ; this . cache = cache ; if ( config . protocol ) { this . protocol = config . protocol ; } if ( config . hostName ) { this . hostName = `://${ config . hostName }` ; } if ( config . versionPath ) { this . versionPath = config . versionPath ; } if ( config . offset ) { this . offset = config . offset - 1 ; } if ( config . limit ) { this . limit = config . limit ; } if ( config . timeout ) { this . timeout = ( config as PokeAPIOptions ) . timeout ; } if ( config . cacheLimit ) { this . cacheLimit = ( config as PokeAPIOptions ) . cacheLimit ; } } } export default PokeAPIOptions ;