-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Service-Soft/dev
Release 18.0.0
- Loading branch information
Showing
50 changed files
with
8,910 additions
and
8,122 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
/* eslint-disable jsdoc/require-jsdoc */ | ||
import { PUSH_SUBSCRIPTIONS } from './in-memory-db'; | ||
import { Request, Response } from 'express'; | ||
import { PushSubscription } from 'web-push'; | ||
|
||
import { PUSH_SUBSCRIPTIONS } from './in-memory-db'; | ||
|
||
export function addPushSubscription(req: Request, res: Response): void { | ||
console.log('received req', req); | ||
PUSH_SUBSCRIPTIONS.push(req.body as unknown as PushSubscription); | ||
res.status(200).json({ message: 'Subscription added successfully.' }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { PushSubscription } from 'web-push'; | ||
|
||
// eslint-disable-next-line jsdoc/require-jsdoc | ||
export const PUSH_SUBSCRIPTIONS: PushSubscription[] = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
/* eslint-disable no-console */ | ||
/* eslint-disable jsdoc/require-jsdoc */ | ||
/* eslint-disable @cspell/spellchecker */ | ||
import { Request, Response } from 'express'; | ||
import * as webpush from 'web-push'; | ||
import * as webPush from 'web-push'; | ||
|
||
import { PUSH_SUBSCRIPTIONS } from './in-memory-db'; | ||
|
||
export function sendNotification(req: Request, res: Response): void { | ||
// sample notification payload | ||
// eslint-disable-next-line typescript/typedef | ||
const notificationPayload = { | ||
notification: { | ||
title: 'Example Notification', | ||
body: 'This notification is testing the ngx-pwa library.', | ||
vibrate: [100, 50, 100], | ||
data: { | ||
'dateOfArrival': Date.now(), | ||
'primaryKey': 1 | ||
dateOfArrival: Date.now(), | ||
primaryKey: 1 | ||
}, | ||
actions: [{ | ||
action: 'explore', | ||
title: 'Go to the site' | ||
}] | ||
actions: [ | ||
{ | ||
action: 'explore', | ||
title: 'Go to the site' | ||
} | ||
] | ||
} | ||
}; | ||
|
||
Promise.all(PUSH_SUBSCRIPTIONS.map(sub => webpush.sendNotification(sub, JSON.stringify(notificationPayload)))) | ||
Promise.all(PUSH_SUBSCRIPTIONS.map(sub => webPush.sendNotification(sub, JSON.stringify(notificationPayload)))) | ||
// eslint-disable-next-line promise/prefer-await-to-then | ||
.then(() => res.status(200).json({ message: 'Notification sent successfully.' })) | ||
.catch(err => { | ||
console.error('Error sending notification, reason: ', err); | ||
// eslint-disable-next-line promise/prefer-await-to-then, promise/prefer-await-to-callbacks | ||
.catch(error => { | ||
console.error('Error sending notification, reason: ', error); | ||
res.sendStatus(500); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const config = require('eslint-config-service-soft'); | ||
|
||
module.exports = [...config]; |
Oops, something went wrong.