eunbeann / web-push

πŸ”” Web Push | Getting Started

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

top

Web Push | Getting Started

Show article

Project

.
β”œβ”€β”€ README.md
β”œβ”€β”€ config
β”‚   └── default.example.json
β”œβ”€β”€ css
β”‚   └── common.css
β”œβ”€β”€ index.html
β”œβ”€β”€ login.html
β”œβ”€β”€ package.json
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ πŸ’» server
β”‚   β”‚   β”œβ”€β”€ constants.ts
β”‚   β”‚   β”œβ”€β”€ logger.ts
β”‚   β”‚   β”œβ”€β”€ middlewares.ts
β”‚   β”‚   β”œβ”€β”€ server.ts
β”‚   β”‚   └── types.ts
β”‚   └── 🌍 web
β”‚       β”œβ”€β”€ index.ts
β”‚       └── service-worker.ts
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ tsconfig.server.json
β”œβ”€β”€ tsconfig.web.json
└── yarn.lock

Setup

  • Pre-requirements
    • = Node 16

    • yarn
      npm i -g yarn
  • create vapid key pairs
    yarn generate-vapid-keys
  • create config/default.json (check config/default.example.json)
    {
      "gcmKey": "GCM API Key HERE",
      "subject": "mailto:your@domain.com",
      "vapid": {
        "public": "PUBLIC KEY HERE",
        "private": "PRIVATE KEY HERE"
      }
    }
    • How to get GCM API key?
      • Visit Google Firebase Console and create project
      • Open Project > Project settings > Cloud Messaging
      • Cloud Messaging API > Server Key
  • setup project
    # Install dependencies
    yarn
    
    # Build scripts (TS -> JS)
    yarn build
    
    # Start demo server
    yarn start

Done! visit http://localhost:8080

Preview

main

notification

About

πŸ”” Web Push | Getting Started


Languages

Language:TypeScript 64.4%Language:CSS 19.6%Language:HTML 16.0%