@runnerpro/backend 1.6.3 → 1.6.4

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.
@@ -13,33 +13,31 @@ exports.sendNotification = void 0;
13
13
  const index_1 = require("../db/index");
14
14
  const sendNotification = ({ firebaseMessaging, idCliente, title, body }) => __awaiter(void 0, void 0, void 0, function* () {
15
15
  const devices = yield (0, index_1.query)('SELECT [SUBSCRIPTION], [TYPE] FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ?', [idCliente]);
16
- return {
17
- devices,
18
- idCliente,
19
- env: process.env.NODE_ENV,
20
- name: process.env.DB_NAME,
21
- };
22
- const promises = [];
23
16
  for (const device of devices) {
24
- promises.push(
25
- // @ts-ignore
26
17
  notificationWEB(firebaseMessaging, {
27
18
  title,
28
19
  body,
29
- }, device.subscription));
20
+ }, device.subscription);
30
21
  }
31
- return promises;
32
22
  });
33
23
  exports.sendNotification = sendNotification;
34
24
  function notificationWEB(firebaseMessaging, msg, token) {
35
25
  return __awaiter(this, void 0, void 0, function* () {
36
26
  if (!msg.title)
37
27
  msg.title = '';
38
- return firebaseMessaging
28
+ firebaseMessaging
39
29
  .send({
40
30
  token,
41
31
  notification: msg,
42
32
  data: msg,
33
+ })
34
+ .catch((error) => {
35
+ if (error.errorInfo.code === 'messaging/registration-token-not-registered') {
36
+ // query(
37
+ // 'DELETE FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ? AND [SUBSCRIPTION] = ?',
38
+ // [idCliente, subscription]
39
+ // );
40
+ }
43
41
  });
44
42
  });
45
43
  }
@@ -4,11 +4,6 @@ interface Notification {
4
4
  title?: string;
5
5
  body: string;
6
6
  }
7
- declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<any[] | {
8
- devices: any;
9
- idCliente: number;
10
- env: string;
11
- name: string;
12
- }>;
7
+ declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<void>;
13
8
  export { sendNotification };
14
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAEA,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;;;;;EA0B1F,CAAC;AAaF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAEA,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;AAqBF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"