@tiledesk/tiledesk-whatsapp-connector 0.1.64 → 0.1.65

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.
package/index.js CHANGED
@@ -1617,29 +1617,37 @@ async function startApp(settings, callback) {
1617
1617
  winston.info("(wab) JOB_TOPIC_EXCHANGE is present");
1618
1618
  }
1619
1619
 
1620
- let LOG_MONGODB_URL;
1621
- if (!settings.LOG_MONGODB_URL) {
1622
- LOG_MONGODB_URL = settings.MONGODB_URL;
1623
- } else {
1624
- LOG_MONGODB_URL = settings.LOG_MONGODB_URL;
1620
+ // For test only
1621
+ if (settings.LOG_MONGODB_URL) {
1622
+ /**
1623
+ * Connect with a different Database
1624
+ */
1625
+ // mongoose
1626
+ // .connect(settings.LOG_MONGODB_URL)
1627
+ // .then(() => {
1628
+ // winston.info("Mongoose DB Connected");
1629
+ // })
1630
+ // .catch((err) => {
1631
+ // winston.error("(Mongoose) Unable to connect with MongoDB ", err);
1632
+ // });
1625
1633
  }
1626
1634
 
1627
- mongoose
1628
- .connect(LOG_MONGODB_URL)
1629
- .then(() => {
1630
- winston.info("Mongoose DB Connected");
1635
+ if (settings.dbconnection) {
1636
+ db.reuseConnection(settings.dbconnection, () => {
1637
+ winston.info("(wab) KVBaseMongo reused exsisting db connection");
1638
+ if (callback) {
1639
+ callback(null);
1640
+ }
1631
1641
  })
1632
- .catch((err) => {
1633
- winston.error("(Mongoose) Unable to connect with MongoDB ", err);
1642
+ } else {
1643
+ db.connect(settings.MONGODB_URL, () => {
1644
+ winston.info("(wab) KVBaseMongo successfully connected.");
1645
+
1646
+ if (callback) {
1647
+ callback(null);
1648
+ }
1634
1649
  });
1635
-
1636
- db.connect(settings.MONGODB_URL, () => {
1637
- winston.info("(wab) KVBaseMongo successfully connected.");
1638
-
1639
- if (callback) {
1640
- callback(null);
1641
- }
1642
- });
1650
+ }
1643
1651
 
1644
1652
  api.startRoute(
1645
1653
  {