diff --git a/src/bling.ts b/src/bling.ts index d15dd38..e1a1cf4 100644 --- a/src/bling.ts +++ b/src/bling.ts @@ -7,7 +7,9 @@ import axios, { AxiosInstance } from 'axios' import createError from './core/createError' export default class Bling { - private api: AxiosInstance + #api: AxiosInstance + #products: Products | undefined + #orders: Orders | undefined constructor (apiKey: string) { if (!apiKey || typeof apiKey !== 'string') { @@ -28,18 +30,23 @@ export default class Bling { apikey: apiKey, ...config.params } - return config }) - this.api = api + this.#api = api } public products () { - return new Products(this.api) + if (!this.#products) { + this.#products = new Products(this.#api) + } + return this.#products } public orders () { - return new Orders(this.api) + if (!this.#orders) { + this.#orders = new Orders(this.#api) + } + return this.#orders } } diff --git a/tsconfig.json b/tsconfig.json index a838a0c..1ee9d6c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "es6", "module": "commonjs", "declaration": true, "outDir": "./lib", @@ -8,6 +8,11 @@ "esModuleInterop": true, "allowJs": true }, - "include": ["src"], - "exclude": ["node_modules", "test/*"] + "include": [ + "src" + ], + "exclude": [ + "node_modules", + "test/*" + ] }