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

notifik

v0.1.0

Published

A simple notification service for push notifications on your phone!

Downloads

3

Readme

Notifik

Browser notifications service made simple.

Notifik is a simple web server that can run on any system running Node.js. It exposes a very simple subscribe page and an API to send push notifications.

The inner workings are quite simple as well, it uses the web push protocol to communicate with the web push service provider (usually FCM (ex-GCM) or Mozilla) and send push notifications to users via Web Service Workers.

It works out of the box but provides some simple configuration options.

Note: This package can handle multiple users

Installation & Usage

Install

npm install -g notifik

Launch

$ notifik

Usage (commands)

notifik version (or -v)

Prints the current version

'notifik path'

Prints the path where you can modify the front-end JS

'notifik keys'

Generate needed keypair

Options

-c ./myconfig.json

Lauches the server using configuration on the provided path. Path must be relative to where the command is launched from.

Subscriptions

Once launched go to /subscribe on any recent browser to subscribe. You should get a confirmation alert. In any case, helpful logs are displayed on the console.

Config

Example configuration file:

{
	"port": 6789,
	"api_key": "this_is_my_super_secure_ley",
	"keys": {
		"public": "public key",
		"private": "private key",
		"gcm": "gcm/fcm key"
	},
	"defaults": {
		"icon": "http://icons.iconarchive.com/icons/papirus-team/papirus-apps/512/preferences-system-notifications-icon.png",
		"badge": "http://icons-for-free.com/free-icons/png/512/2246841.png"
	},
	"service_worker": "/js/workers/notifier.js"
}

Note: api_key can be set to null if you don't want to use one. (WHY?)

In order to generate a key pair you can use notifik keys. To get a gcm key please go to Firebase, and create a new project. Once in your project go to the "Project Settings" (upper left, gear icon) and click on the Cloud Messaging tab, you can find your Server Key which is your gcm key.

API

The API can be protected by an api_key (set in the config file, see Config) and, if set, MUST be included in all (except two) request to /api whether as a query param (/api/notify?api_key=<your key>) or a header (X-Api-Key: <your key>).

GET /config

Is not protected by API key.

Returns simple config info for the front end:

{
	service_worker: 'path/to/sw.js'
}

POST /subscribe

Is not protected by API key.

Subscribes a user to the notifications system

Params
{
	id: 'some unique id',
	subscription: {
		// subscription info from push manager
	}
}

GET /subscriptions

Returns all active subscription ids.

['id1', 'id2', 'id3']

POST /notify

Send a push notification to a subscriber

Params

{
	id: 'some_unique_id',
	...params 
}

Notification parameters can be found here

POST /notify/bulk

Send a push notification to a subscriber

Params (same notification for everyone)

{
	users: ['id1', 'id2'],
	notification: {
		...params
	}
}

Params (different notifications)

{
	users: [{
		id: 'unique_id',
		...params
	}, {
		id: 'unique_id2',
		...params
	}]
}

POST /update

Send an update notification to all subscribers to update service worker. This is useful when you add actions or modify the behaviour of your web worker.

Please note that once your web worker is installed, changing the path will not trigger an update, the browser remembers the same path: never change your web worker path, or a new subscription must be made.