@runnerpro/backend 1.0.1 → 1.0.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.
|
@@ -11,10 +11,8 @@ 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]);
|
|
19
17
|
for (const device of devices) {
|
|
20
18
|
if (device.type === 'IOS') {
|
|
@@ -24,7 +22,7 @@ const sendNotification = ({ idCliente, title, body, url, }) => __awaiter(void 0,
|
|
|
24
22
|
}, device.subscription);
|
|
25
23
|
}
|
|
26
24
|
else {
|
|
27
|
-
notificationWEB(
|
|
25
|
+
notificationWEB(firebaseMessaging, {
|
|
28
26
|
title,
|
|
29
27
|
body,
|
|
30
28
|
url: process.env.FRONTEND_URL + url,
|
|
@@ -51,9 +49,9 @@ function notificationIOS(msg, token) {
|
|
|
51
49
|
apnProvider.send(note, token);
|
|
52
50
|
});
|
|
53
51
|
}
|
|
54
|
-
function notificationWEB(
|
|
52
|
+
function notificationWEB(firebaseMessaging, msg, token) {
|
|
55
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
|
|
54
|
+
firebaseMessaging
|
|
57
55
|
.send({
|
|
58
56
|
token,
|
|
59
57
|
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":"
|
|
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,kBA2Bd,CAAC;AA+CF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runnerpro/backend",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A collection of common backend functions",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/cjs/index.js"
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@types/chai": "4.3.3",
|
|
37
37
|
"@types/mocha": "9.1.1",
|
|
38
38
|
"chai": "4.3.6",
|
|
39
|
+
"del-cli": "5.0.0",
|
|
39
40
|
"mocha": "10.0.0",
|
|
40
41
|
"semantic-release": "19.0.3",
|
|
41
42
|
"ts-node": "10.9.1",
|
|
@@ -43,7 +44,6 @@
|
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
46
|
"@parse/node-apn": "6.0.1",
|
|
46
|
-
"firebase-admin": "11.10.1",
|
|
47
47
|
"nodemailer": "6.9.9",
|
|
48
48
|
"pg": "8.11.3"
|
|
49
49
|
},
|