@runnerpro/backend 1.0.0 → 1.0.3

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.
@@ -11,11 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.sendNotification = void 0;
13
13
  const apn = require('@parse/node-apn');
14
- const { getMessaging } = require('firebase-admin/messaging');
15
14
  const { query } = require('../db');
16
- const sendNotification = ({ idCliente, title, body, url, }) => __awaiter(void 0, void 0, void 0, function* () {
17
- const messaging = getMessaging();
15
+ const sendNotification = ({ firebaseMessaging, idCliente, title, body, url, }) => __awaiter(void 0, void 0, void 0, function* () {
18
16
  const devices = yield query('SELECT [SUBSCRIPTION], [TYPE] FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ?', [idCliente]);
17
+ console.log(devices);
19
18
  for (const device of devices) {
20
19
  if (device.type === 'IOS') {
21
20
  notificationIOS({
@@ -24,7 +23,7 @@ const sendNotification = ({ idCliente, title, body, url, }) => __awaiter(void 0,
24
23
  }, device.subscription);
25
24
  }
26
25
  else {
27
- notificationWEB(messaging, {
26
+ notificationWEB(firebaseMessaging, {
28
27
  title,
29
28
  body,
30
29
  url: process.env.FRONTEND_URL + url,
@@ -48,12 +47,19 @@ function notificationIOS(msg, token) {
48
47
  note.expiry = Math.floor(Date.now() / 1000) + 3600 * 24; // Expires 24 hour from now.
49
48
  note.alert = { title: 'RunnerPro', subtitle: msg.title, body: msg.body };
50
49
  note.topic = 'ios.runnerpro.cliente';
51
- apnProvider.send(note, token);
50
+ apnProvider
51
+ .send(note, token)
52
+ .then((result) => {
53
+ console.log(result);
54
+ })
55
+ .catch((error) => {
56
+ console.log(error);
57
+ });
52
58
  });
53
59
  }
54
- function notificationWEB(messaging, msg, token) {
60
+ function notificationWEB(firebaseMessaging, msg, token) {
55
61
  return __awaiter(this, void 0, void 0, function* () {
56
- messaging
62
+ firebaseMessaging
57
63
  .send({
58
64
  token,
59
65
  data: msg,
@@ -1,9 +1,10 @@
1
1
  interface Notification {
2
+ firebaseMessaging: any;
2
3
  idCliente: number;
3
4
  title: string;
4
5
  body: string;
5
6
  url: string;
6
7
  }
7
- declare const sendNotification: ({ idCliente, title, body, url, }: Notification) => Promise<void>;
8
+ declare const sendNotification: ({ firebaseMessaging, idCliente, title, body, url, }: Notification) => Promise<void>;
8
9
  export { sendNotification };
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAIA,UAAU,YAAY;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,QAAA,MAAM,gBAAgB,qCAKnB,YAAY,kBA4Bd,CAAC;AA+CF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAGA,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,QAAA,MAAM,gBAAgB,wDAMnB,YAAY,kBA6Bd,CAAC;AAsDF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"
@@ -30,36 +30,23 @@
30
30
  "type": "git",
31
31
  "url": "https://gitlab.com/runner-pro/runnerpro-backend.git"
32
32
  },
33
- "keywords": [
34
- "npm",
35
- "javascript",
36
- "typescript",
37
- "cjs",
38
- "nodejs",
39
- "commonjs",
40
- "ecmascript",
41
- "beginner",
42
- "example",
43
- "demonstration"
44
- ],
45
33
  "author": "Runner Pro",
46
34
  "license": "MIT",
47
35
  "devDependencies": {
48
- "@types/chai": "^4.3.3",
49
- "@types/mocha": "^9.1.1",
50
- "chai": "^4.3.6",
51
- "del-cli": "^5.0.0",
52
- "mocha": "^10.0.0",
53
- "move-file-cli": "^3.0.0",
54
- "semantic-release": "^19.0.3",
55
- "ts-node": "^10.9.1",
56
- "typescript": "^4.7.4"
36
+ "@types/chai": "4.3.3",
37
+ "@types/mocha": "9.1.1",
38
+ "chai": "4.3.6",
39
+ "del-cli": "5.0.0",
40
+ "mocha": "10.0.0",
41
+ "semantic-release": "19.0.3",
42
+ "ts-node": "10.9.1",
43
+ "typescript": "4.7.4"
57
44
  },
58
45
  "peerDependencies": {
59
- "@parse/node-apn": "^6.0.1",
60
- "firebase-admin": "^12.0.0",
61
- "nodemailer": "^6.9.9",
62
- "pg": "^8.11.3"
46
+ "@parse/node-apn": "6.0.1",
47
+ "firebase-admin": "11.10.1",
48
+ "nodemailer": "6.9.9",
49
+ "pg": "8.11.3"
63
50
  },
64
51
  "dependencies": {}
65
52
  }