@natyapp/meta 1.6.5 → 1.6.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.
@@ -32,13 +32,17 @@ const connectionRouter = (naty) => {
32
32
  if (!accountInfo)
33
33
  throw new Error("Não foi possível encontrar Account");
34
34
  dataReturn.accountInfo = accountInfo;
35
+ naty.emit("connection", dataReturn);
36
+ res.json({ connection: req.body });
35
37
  }
36
38
  catch (err) {
37
- throw new Error(err);
39
+ console.log(err);
40
+ naty.emit("error", err);
41
+ res.status(500).json({
42
+ error: err.message,
43
+ });
38
44
  }
39
45
  }
40
- naty.emit("connection", dataReturn);
41
- res.json({ connection: req.body });
42
46
  });
43
47
  return router;
44
48
  };
@@ -8,11 +8,20 @@ const messagesRouter = (naty) => {
8
8
  const router = (0, express_1.Router)();
9
9
  router.post("/", (req, res) => {
10
10
  var _a, _b, _c, _d, _e, _f, _g;
11
- const { companyId, data } = req.body;
12
- const phone_number_id = (_c = (_b = (_a = data.entry[0]) === null || _a === void 0 ? void 0 : _a.changes[0]) === null || _b === void 0 ? void 0 : _b.value.metadata) === null || _c === void 0 ? void 0 : _c.phone_number_id;
13
- const clientNumber = (_g = (_f = (_e = (_d = data.entry[0]) === null || _d === void 0 ? void 0 : _d.changes[0]) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.contacts[0]) === null || _g === void 0 ? void 0 : _g.wa_id;
14
- naty.emit("message", new whatsappResponse_1.WhatsappResponse(companyId, phone_number_id, clientNumber, new whatsappMessage_1.WhatsappMessage(data)));
15
- res.json(true);
11
+ try {
12
+ const { companyId, data } = req.body;
13
+ const phone_number_id = (_c = (_b = (_a = data.entry[0]) === null || _a === void 0 ? void 0 : _a.changes[0]) === null || _b === void 0 ? void 0 : _b.value.metadata) === null || _c === void 0 ? void 0 : _c.phone_number_id;
14
+ const clientNumber = (_g = (_f = (_e = (_d = data.entry[0]) === null || _d === void 0 ? void 0 : _d.changes[0]) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.contacts[0]) === null || _g === void 0 ? void 0 : _g.wa_id;
15
+ naty.emit("message", new whatsappResponse_1.WhatsappResponse(companyId, phone_number_id, clientNumber, new whatsappMessage_1.WhatsappMessage(data)));
16
+ res.json(true);
17
+ }
18
+ catch (err) {
19
+ console.log(err);
20
+ naty.emit("error", err);
21
+ res.status(500).json({
22
+ error: err.message,
23
+ });
24
+ }
16
25
  });
17
26
  return router;
18
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@natyapp/meta",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",