More logging on web-service calls and Promise replacement for forEach.

This commit is contained in:
Rodrigo Rodriguez 2018-09-09 16:18:26 -03:00
parent 0ce8d48f09
commit f62399c912
3 changed files with 82 additions and 67 deletions

View file

@ -74,7 +74,7 @@ export class ConsoleDirectLine extends GBService {
// TODO: Remove *this* issue.
let _this_ = this;
directLineClient.then(function (client) {
directLineClient.then((client)=> {
client.Conversations.Conversations_StartConversation()
.then(function (response) {
return response.obj.conversationId;
@ -149,7 +149,7 @@ export class ConsoleDirectLine extends GBService {
// print other messages
activities.forEach(activity => {
console.log(activity.text);
});
}, this);
process.stdout.write('Command> ');
}

View file

@ -106,7 +106,7 @@ export class GBMinService {
// Gets the authorization key for each instance from Bot Service.
Promise.all(instances).then(async (instance: IGBInstance) => {
Promise.all(instances.map(async instance => {
let options = {
url:
@ -117,13 +117,22 @@ export class GBMinService {
}
};
let responseObject: any;
try {
let response = await request(options);
responseObject = JSON.parse(response);
} catch (error) {
logger.error(`Error calling Direct Line client, verify Bot endpoint on the cloud. Error is: ${error}.`);
return;
}
// Serves the bot information object via http so clients can get
// instance information stored on server.
let responseObject = JSON.parse(response);
server.get("/instances/:botId", (req, res) => {
logger.info('test');
(async () => {
// Returns the instance object to clients requesting bot info.
@ -143,7 +152,14 @@ export class GBMinService {
}
};
let response: any;
try {
response = await request(options);
responseObject = JSON.parse(response);
} catch (error) {
logger.error(`Error calling Speech to Text client. Error is: ${error}.`);
return;
}
res.send(
JSON.stringify({
@ -202,11 +218,10 @@ export class GBMinService {
p["channel"].received(req, res);
});
}
});
}, this);
e.loadBot(min);
});
}, this);
// Serves individual URL for each bot conversational interface...
@ -326,13 +341,13 @@ export class GBMinService {
// next();
// Specialized load for each min instance.
});
}));
}
/** Performs package deployment in all .gbai or default. */
public deployPackages(core: IGBCoreService, server: any, appPackages: Array<IGBPackage>) {
let _this = this;
return new Promise((resolve, reject) => {
try {
let totalPackages = 0;
@ -398,7 +413,7 @@ export class GBMinService {
} else {
appPackagesProcessed++;
}
});
}, _this);
WaitUntil()
@ -411,16 +426,15 @@ export class GBMinService {
.done(function (result) {
logger.info(`App Package deployment done.`);
core.syncDatabaseStructure(cb => {
core.syncDatabaseStructure();
/** Deploys all .gbot files first. */
botPackages.forEach(e => {
logger.info(`Deploying bot: ${e}...`);
this.deployer.deployBot(e, (data, err) => {
_this.deployer.deployBot(e);
logger.info(`Bot: ${e} deployed...`);
});
});
}, _this);
/** Then all remaining generalPackages are loaded. */
@ -481,7 +495,7 @@ export class GBMinService {
resolve();
});
});
});
} catch (err) {
logger.error(err);
reject(err)

View file

@ -31,6 +31,7 @@
},
"dependencies": {
"async": "^2.6.1",
"async-promises": "^0.2.1",
"body-parser": "^1.18.3",
"botbuilder": "^4.0.0-preview1.2",
"botbuilder-ai": "^4.0.0-preview1.2",
@ -52,12 +53,12 @@
"sequelize": "^4.38.0",
"sequelize-typescript": "^0.6.6",
"sqlite3": "^4.0.2",
"swagger-client": "^3.8.15",
"swagger-client": "^3.8.19",
"tedious": "^2.6.4",
"url-join": "^4.0.0",
"wait-until": "^0.0.2",
"walk-promise": "^0.2.0",
"winston": "^3.0.0"
"winston": "^3.1.0"
},
"devDependencies": {
"@types/chai": "^4.1.4",