- cleaned some code.
- routing offline - pushNotification
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
var os = require("os");
|
||||
|
||||
// SETTINGS WebPush Configuration
|
||||
const webpush = require('web-push');
|
||||
|
||||
const publicVapidKey = process.env.PUBLIC_VAPI_KEY;
|
||||
const privateVapidKey = process.env.PRIVATE_VAPI_KEY;
|
||||
webpush.setVapidDetails('mailto:' + process.env.EMAIL_FROM, publicVapidKey, privateVapidKey);
|
||||
|
||||
module.exports = {
|
||||
getHostname: function () {
|
||||
return os.hostname()
|
||||
@@ -17,7 +24,7 @@ module.exports = {
|
||||
// doing nothing
|
||||
},
|
||||
|
||||
mylogshow: function (...args) {
|
||||
mylogshow: function (...args) {
|
||||
console.log(args)
|
||||
},
|
||||
|
||||
@@ -28,6 +35,14 @@ module.exports = {
|
||||
|
||||
allfieldTodoWithId: function () {
|
||||
return ['_id', ...this.allfieldTodo()]
|
||||
},
|
||||
|
||||
sendBackNotif: function (subscription, payload) {
|
||||
|
||||
// console.log('sendBackNotif:', subscription, payload);
|
||||
// Pass object into sendNotification
|
||||
webpush.sendNotification(subscription, JSON.stringify(payload)).catch(err => console.error(err));
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user