new(all): TRUE multicloud.
This commit is contained in:
parent
367e45f5f5
commit
6bc15e1a74
1 changed files with 10 additions and 11 deletions
21
src/util.ts
21
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 => {
|
||||
|
|
Loading…
Add table
Reference in a new issue