npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pushilka

v2.0.1

Published

Web push client

Downloads

3

Readme

Pushilka

Description

Web-Push notifications client library. In order to get it works you need:

  • Have HTTPS set up.
  • Configure your web server to serve app.js and serviceWorker.js files from the same domain, where content is served from. If you use CDN for static files like css, js and imaged this two files MUST NOT be served from CDN.
  • Configure your web server to send Service-Worker-Allowed: / header for serviceWorker.js file.
  • Configure your web server NOT to cache app.js and serviceWorker.js files.

Installation

npm install pushilka

Usage

var pushilka = new Pushilka({
    source: "<source token>",
    serviceWorker: "/node_modules/pushilka/dist/serviceWorker.js"
})
pushilka.run()

Options

  • endpoint - endpoint where subscription will be sent to. (Default: https://push.wuazu.net/push_subscription.php)
  • serviceWorker - path to service worker. Not that service worker MUST be served from the same domain (Default: "/serviceWorker.js")
  • serviceWorkerOptions - service worker options. (Default: {scope: "/"}),
  • applicationServerKey - public key that the push server will use to authenticate your application server.
  • source - you will obtain this from pushilka's team
  • var1, var2, var3, var4 - custom tracking parameters.
  • done - callback that will be called when user press Allow or Deny

Nginx configuration example

location ~ /node_modules/pushilka/dist/(serviceWorker|app).js$ {
    add_header 'Service-Worker-Allowed' '/';
    expires -1;
}

Apache configuration example

<Location ~ "/(serviceWorker|app).js$">
    Header set Service-Worker-Allowed /
    Header unset ETag
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</Location>

CloudFront configuration

  1. Deploy pushilka-cloudfront-headers application. During deployment you will be asked for application name, choose any you want. For example "pushilka".
  2. Go to the Servies -> IAM -> Roles and find recently created role for your function. If begins with aws-serverless-repository-pushilka-*. Open Role and under Trust relationships change the line:
"Service": "lambda.amazonaws.com"

with the following:

"Service": [
    "lambda.amazonaws.com",
    "edgelambda.amazonaws.com"
]
  1. Find and open created function (Services -> Lambda -> Functions). Open it and publish new version of function. Choose Publish new version under Actions menu.
  2. In the new version find CloufFront in Designer block and then enter CloudFront distribution which serves your js files and choose Origin Response event. Also selected "Enable trigger and replicate". Then press Add and Save function.
  3. Go to the Services -> CloudFront and wait until your distribution change state to Deployed. Then check, that headers are sent correctly.