@tiledesk/tiledesk-tybot-connector 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,28 +22,33 @@ class MongodbBotsDataSource {
22
22
  async getBotByIdCache(botId, tdcache) {
23
23
  let bot = null;
24
24
  if (tdcache) {
25
+ console.log("getBotByIdCache cache ok");
25
26
  let botCacheKey = "cacheman:cachegoose-cache:faq_kbs:id:" + botId;
26
27
  try {
27
28
  let _bot_as_string = await tdcache.get(botCacheKey);
28
29
  const value_type = typeof _bot_as_string;
29
- if (this.log) {
30
- console.log("__bot_as_string found in chache:", _bot_as_string);
31
- console.log("value_type:", value_type);
32
- }
30
+ console.log("__bot_as_string found in chache:", _bot_as_string);
31
+ // if (this.log) {
32
+ // console.log("__bot_as_string found in chache:", _bot_as_string);
33
+ // console.log("value_type:", value_type);
34
+ // }
33
35
  if (_bot_as_string) {
34
36
  bot = JSON.parse(_bot_as_string);
35
- if (this.log) {
36
- console.log("got bot from cache:", JSON.stringify(bot));
37
- }
37
+ console.log("got bot from cache:", JSON.stringify(bot));
38
+ // if (this.log) {
39
+ // console.log("got bot from cache:", JSON.stringify(bot));
40
+ // }
38
41
  }
39
42
  else {
40
- if (this.log) {
41
- console.log("bot not found, getting from datasource...");
42
- }
43
+ console.log("bot not found, getting from datasource...");
44
+ // if (this.log) {
45
+ // console.log("bot not found, getting from datasource...");
46
+ // }
43
47
  bot = await this.getBotById(botId);
44
- if (this.log) {
45
- console.log("bot found in datasource:", JSON.stringify(bot));
46
- }
48
+ console.log("bot found in datasource:", JSON.stringify(bot));
49
+ // if (this.log) {
50
+ // console.log("bot found in datasource:", JSON.stringify(bot));
51
+ // }
47
52
  await tdcache.set(botCacheKey, JSON.stringify(bot));
48
53
  // DEBUG CODE REMOVE
49
54
  // let bot_ = await tdcache.get(botCacheKey);
@@ -55,13 +60,13 @@ class MongodbBotsDataSource {
55
60
  }
56
61
  }
57
62
  else {
58
- if (this.log) {
63
+ // if (this.log) {
59
64
  console.log("no chache. getting bot from datasource...");
60
- }
65
+ // }
61
66
  bot = await this.getBotById(botId);
62
- if (this.log) {
67
+ // if (this.log) {
63
68
  console.log("bot found in datasource:", JSON.stringify(bot));
64
- }
69
+ // }
65
70
  }
66
71
  return bot;
67
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -151,10 +151,10 @@ class DirReply {
151
151
  }
152
152
 
153
153
  myrequest(options, callback, log) {
154
- if (log) {
154
+ // if (log) {
155
155
  console.log("API URL:", options.url);
156
156
  console.log("** Options:", JSON.stringify(options));
157
- }
157
+ // }
158
158
  axios(
159
159
  {
160
160
  url: options.url,
@@ -167,9 +167,13 @@ class DirReply {
167
167
  // if (log) {
168
168
  console.log("Reply: Response for url:", options.url);
169
169
  console.log("Reply: Response headers:\n", JSON.stringify(res.headers));
170
+ console.log("Reply: Status:", res.status);
171
+ console.log("Reply: Data:", res.data);
172
+
170
173
  //console.log("******** Response for url:", res);
171
174
  // }
172
175
  if (res && res.status == 200 && res.data) {
176
+ console.error("Status 200 OK");
173
177
  if (callback) {
174
178
  callback(null, res.data);
175
179
  }