From 6bc15e1a74c3e79b1ba9122e7619133dbfd4f8d1 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Tue, 20 Aug 2024 15:30:47 -0300 Subject: [PATCH] new(all): TRUE multicloud. --- src/util.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/util.ts b/src/util.ts index ca2dadc1..fe4045a9 100644 --- a/src/util.ts +++ b/src/util.ts @@ -69,31 +69,30 @@ export class GBUtil { public static async getDirectLineClient(min) { let config = { - url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages`, spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')), requestInterceptor: req => { req.headers['Authorization'] = `Bearer ${min.instance.webchatKey}`; } }; - if (!GBConfigService.get('STORAGE_NAME')) { - config['spec'].servers = [{ url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages` }]; + if (GBConfigService.get('STORAGE_FILE')) { + (config['url'] = `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages`), + (config['spec'].servers = [{ url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages` }]); config['openapi'] = '3.0.0'; } - return await new SwaggerClient(config); } public static toYAML(data) { - const extractProps = (obj) => { - return Object.getOwnPropertyNames(obj).reduce((acc, key) => { - const value = obj[key]; - acc[key] = value && typeof value === 'object' && !Array.isArray(value) ? extractProps(value) : value; - return acc; - }, {}); + const extractProps = obj => { + return Object.getOwnPropertyNames(obj).reduce((acc, key) => { + const value = obj[key]; + acc[key] = value && typeof value === 'object' && !Array.isArray(value) ? extractProps(value) : value; + return acc; + }, {}); }; const extractedError = extractProps(data); return YAML.stringify(extractedError); -} + } public static sleep(ms) { return new Promise(resolve => {