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) {
|
public static async getDirectLineClient(min) {
|
||||||
let config = {
|
let config = {
|
||||||
url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages`,
|
|
||||||
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
||||||
requestInterceptor: req => {
|
requestInterceptor: req => {
|
||||||
req.headers['Authorization'] = `Bearer ${min.instance.webchatKey}`;
|
req.headers['Authorization'] = `Bearer ${min.instance.webchatKey}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!GBConfigService.get('STORAGE_NAME')) {
|
if (GBConfigService.get('STORAGE_FILE')) {
|
||||||
config['spec'].servers = [{ url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages` }];
|
(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';
|
config['openapi'] = '3.0.0';
|
||||||
}
|
}
|
||||||
return await new SwaggerClient(config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static toYAML(data) {
|
public static toYAML(data) {
|
||||||
const extractProps = (obj) => {
|
const extractProps = obj => {
|
||||||
return Object.getOwnPropertyNames(obj).reduce((acc, key) => {
|
return Object.getOwnPropertyNames(obj).reduce((acc, key) => {
|
||||||
const value = obj[key];
|
const value = obj[key];
|
||||||
acc[key] = value && typeof value === 'object' && !Array.isArray(value) ? extractProps(value) : value;
|
acc[key] = value && typeof value === 'object' && !Array.isArray(value) ? extractProps(value) : value;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
const extractedError = extractProps(data);
|
const extractedError = extractProps(data);
|
||||||
return YAML.stringify(extractedError);
|
return YAML.stringify(extractedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static sleep(ms) {
|
public static sleep(ms) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue