aeremmiddleware 1.0.10 → 1.0.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.
package/dist/index.d.ts CHANGED
@@ -10,4 +10,7 @@ export declare const AeremMiddleware: {
10
10
  whatsapp: typeof import("./Socials/whatsApp").default;
11
11
  text: typeof import("./Socials/SmsSender").default;
12
12
  };
13
+ push: {
14
+ pushNoti: typeof import("./pushNotification/pushNotificationFCM").sendPushNotification;
15
+ };
13
16
  };
package/dist/index.js CHANGED
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AeremMiddleware = void 0;
4
4
  const Finance_1 = require("./Finance");
5
5
  const Socials_1 = require("./Socials");
6
+ const pushNotification_1 = require("./pushNotification");
6
7
  exports.AeremMiddleware = {
7
- finance: Finance_1.finance, socials: Socials_1.socials
8
+ finance: Finance_1.finance,
9
+ socials: Socials_1.socials,
10
+ push: pushNotification_1.push,
8
11
  };
9
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AACpC,uCAAoC;AAGtB,QAAA,eAAe,GAAG;IAC5B,OAAO,EAAP,iBAAO,EAAC,OAAO,EAAP,iBAAO;CAElB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AACpC,uCAAoC;AACpC,yDAA0C;AAE7B,QAAA,eAAe,GAAG;IAC7B,OAAO,EAAP,iBAAO;IACP,OAAO,EAAP,iBAAO;IACP,IAAI,EAAJ,uBAAI;CACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { sendPushNotification } from "./pushNotificationFCM";
2
+ export declare const push: {
3
+ pushNoti: typeof sendPushNotification;
4
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.push = void 0;
4
+ const pushNotificationFCM_1 = require("./pushNotificationFCM");
5
+ exports.push = {
6
+ pushNoti: pushNotificationFCM_1.sendPushNotification,
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pushNotification/index.ts"],"names":[],"mappings":";;;AAAA,+DAA6D;AAEhD,QAAA,IAAI,GAAG;IAClB,QAAQ,EAAE,0CAAoB;CAC/B,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function sendPushNotification(serverKey: string, registrationIds: string[], title: string, body: string, data: {}, icon?: string, sound?: string): Promise<any>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.sendPushNotification = void 0;
13
+ const FCM = require("fcm-node");
14
+ function sendPushNotification(serverKey, registrationIds, title, body, data, icon, sound) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const fcm = new FCM(serverKey);
17
+ return new Promise((resolve, reject) => {
18
+ const pushMessage = {
19
+ registration_ids: registrationIds,
20
+ notification: {
21
+ body: body,
22
+ icon: icon || "myicon",
23
+ sound: sound || "mySound",
24
+ title: title,
25
+ },
26
+ data: data,
27
+ };
28
+ fcm.send(pushMessage, (err, response) => {
29
+ if (err) {
30
+ console.log("Something has gone wrong!", err);
31
+ reject(err);
32
+ }
33
+ else {
34
+ console.log("Push notification sent.", response);
35
+ resolve(response);
36
+ }
37
+ });
38
+ });
39
+ });
40
+ }
41
+ exports.sendPushNotification = sendPushNotification;
42
+ //# sourceMappingURL=pushNotificationFCM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushNotificationFCM.js","sourceRoot":"","sources":["../../src/pushNotification/pushNotificationFCM.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEhC,SAAsB,oBAAoB,CACxC,SAAgB,EAChB,eAAyB,EACzB,KAAa,EACb,IAAY,EACZ,IAAQ,EACR,IAAa,EACb,KAAc;;QAEd,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;QAE/B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,WAAW,GAAG;gBAClB,gBAAgB,EAAE,eAAe;gBACjC,YAAY,EAAE;oBACZ,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,IAAI,IAAI,QAAQ;oBACtB,KAAK,EAAE,KAAK,IAAI,SAAS;oBACzB,KAAK,EAAE,KAAK;iBACb;gBACD,IAAI,EAAE,IAAI;aACX,CAAC;YAEF,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAQ,EAAE,QAAa,EAAE,EAAE;gBAChD,IAAI,GAAG,EAAE;oBACP,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;oBAC9C,MAAM,CAAC,GAAG,CAAC,CAAC;iBACb;qBAAM;oBACL,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;oBACjD,OAAO,CAAC,QAAQ,CAAC,CAAC;iBACnB;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAjCD,oDAiCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aeremmiddleware",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "type": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { finance } from "./Finance";
2
2
  import { socials } from "./Socials";
3
+ import { push } from "./pushNotification";
3
4
 
4
-
5
- export const AeremMiddleware = {
6
- finance,socials
7
-
8
- }
5
+ export const AeremMiddleware = {
6
+ finance,
7
+ socials,
8
+ push,
9
+ };
@@ -0,0 +1,5 @@
1
+ import { sendPushNotification } from "./pushNotificationFCM";
2
+
3
+ export const push = {
4
+ pushNoti: sendPushNotification,
5
+ };
@@ -0,0 +1,36 @@
1
+ const FCM = require("fcm-node");
2
+
3
+ export async function sendPushNotification(
4
+ serverKey:string,
5
+ registrationIds: string[],
6
+ title: string,
7
+ body: string,
8
+ data: {},
9
+ icon?: string,
10
+ sound?: string,
11
+ ): Promise<any> {
12
+ const fcm = new FCM(serverKey);
13
+
14
+ return new Promise((resolve, reject) => {
15
+ const pushMessage = {
16
+ registration_ids: registrationIds,
17
+ notification: {
18
+ body: body,
19
+ icon: icon || "myicon",
20
+ sound: sound || "mySound",
21
+ title: title,
22
+ },
23
+ data: data,
24
+ };
25
+
26
+ fcm.send(pushMessage, (err: any, response: any) => {
27
+ if (err) {
28
+ console.log("Something has gone wrong!", err);
29
+ reject(err);
30
+ } else {
31
+ console.log("Push notification sent.", response);
32
+ resolve(response);
33
+ }
34
+ });
35
+ });
36
+ }