Skip to content

Basic PoC to show how to notify (push) a subscriber PWA

Notifications You must be signed in to change notification settings

Frac7/ExpressPWAShifts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpressPWAShifts

Basic PoC to show how to notify (push) a subscriber PWA. This example is based on this resource.

Overview

This project was created with:

  • Express to manage REST APIs;
  • Cron Node to manage the push notification schedule;
  • Web Push to manage encryption and sending notifications.

Registration flow

  1. First, the PWA has to query the server to get the public key for the encryption step: GET /public-key;
  2. Then the PWA has to send the subscription details to the server: POST /subscription.

For simplicity, each subscription is stored in a simple in-memory data structure. Each subscription is identified by the endpoint, see Introduction to push notification.

A scheduled job runs every day at 8:00 am - the server sends a notification for each registered client.

Get the turns

The last endpoint exposed by this application is GET /, which returns shifts for a certain date. Shifts are mocked within the application.

Getting started

Generate VAPID keys and save them in the .env file using webPush.generateVAPIDKeys (). webPush derives from the web-push package. See Push.

Run the following command: yarn install && yarn start

About

Basic PoC to show how to notify (push) a subscriber PWA

Topics

Resources

Stars

Watchers

Forks