@runnerpro/backend 1.5.11 → 1.5.12

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.
@@ -8,75 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.sendNotification = void 0;
16
- const node_apn_1 = __importDefault(require("@parse/node-apn"));
17
13
  const index_1 = require("../db/index");
18
14
  const sendMail_1 = require("../sendMail");
19
15
  const sendNotification = ({ firebaseMessaging, idCliente, title, body }) => __awaiter(void 0, void 0, void 0, function* () {
20
16
  const devices = yield (0, index_1.query)('SELECT [SUBSCRIPTION], [TYPE] FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ?', [idCliente]);
21
17
  for (const device of devices) {
22
- /*if (['IOS', 'ios'].includes(device.type)) {
23
- notificationIOS(
24
- {
25
- title,
26
- body,
27
- },
28
- device.subscription
29
- );
30
- } else { */
31
18
  notificationWEB(firebaseMessaging, {
32
19
  title,
33
20
  body
34
21
  }, device.subscription);
35
- // }
36
22
  }
37
23
  });
38
24
  exports.sendNotification = sendNotification;
39
- function notificationIOS(msg, token) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const options = {
42
- token: {
43
- key: 'env/apple_notification.p8',
44
- keyId: '49XT5X2ZYD',
45
- teamId: 'UA78D3SXQG',
46
- },
47
- production: true,
48
- };
49
- const apnProvider = new node_apn_1.default.Provider(options);
50
- const note = new node_apn_1.default.Notification();
51
- note.expiry = Math.floor(Date.now() / 1000) + 3600 * 24; // Expires 24 hour from now.
52
- note.alert = {
53
- title: 'RunnerPro',
54
- subtitle: msg.title || '',
55
- body: msg.body,
56
- };
57
- note.topic = 'ios.runnerpro.cliente';
58
- note.pushType = 'alert';
59
- note.priority = 10;
60
- try {
61
- const result = yield apnProvider.send(note, token);
62
- (0, sendMail_1.sendMail)({
63
- to: ['david.jimenez@runnerpro.app'],
64
- subject: 'Notificación APN enviada',
65
- title: 'Notificación APN enviada',
66
- body: JSON.stringify(result),
67
- });
68
- }
69
- catch (error) {
70
- (0, sendMail_1.sendMail)({
71
- to: ['david.jimenez@runnerpro.app'],
72
- subject: 'Error enviando notificación APN',
73
- title: 'Error enviando notificación APN',
74
- body: JSON.stringify(error),
75
- });
76
- }
77
- apnProvider.shutdown();
78
- });
79
- }
80
25
  function notificationWEB(firebaseMessaging, msg, token) {
81
26
  return __awaiter(this, void 0, void 0, function* () {
82
27
  if (!msg.title)
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAIA,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,gBAAgB,kDAAyD,YAAY,kBAuB1F,CAAC;AA8EF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAIA,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,gBAAgB,kDAAyD,YAAY,kBAa1F,CAAC;AAmCF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.5.11",
3
+ "version": "1.5.12",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"