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

push-node-lib

v1.0.6

Published

The library supports sending messages from the app server to the push server ### Set up user information with Push notification server After the user login successfully, you need to send the user information to the push notification server using the fol

Downloads

6

Readme

Push notification

The library supports sending messages from the app server to the push server

Set up user information with Push notification server

After the user login successfully, you need to send the user information to the push notification server using the following function:

var jwt = require('json-web-token');
var PushNotification = require('push-node-lib');
var setupUser = () =>{ 
    //The API_KEY of the project is encoded using the JSON Web Token that contains projectId    
    //The following statement takes the id of the current project and saves it to the projectId variable   
    var PROJECT_ID = jwt.decode(API_KEY).projectId;
    //The following command creates a push notification with the following parameters:    
    //id of project, url of push notification server, API_KEY of project    
    var pushNotification = new PushNotification(PROJECT_ID, NOTIFICATION_URL, API_KEY);    
    //Then call setupUser function with parameters:    
    //id of current user, true if user allow, false if now allow   
    //This function return the token of current user    
    return pushNotification.setupUser(USER_ID, true);
}

This function returns the token of the current user. You need to store this token in your browser's cookie as "token" for the client-side library. For example:

var token = setupUser();    
if (token != null) {      
    res.cookie('token', token);    
}

Send a notification to the user

var jwt = require('json-web-token');
var PushNotification = require('push-node-lib');
var sendToPushServer = () => {      
    //The API_KEY of the project is encoded using the JSON Web Token that contains projectId    
    //The following statement takes the id of the current project and saves it to the projectId variable    
    var PROJECT_ID = jwt.decode(API_KEY).projectId;    
    //The following command creates a push notification with the following parameters:
    //id of project, url of push notification server, API_KEY of project    
    var pushNotification = new PushNotification(PROJECT_ID, NOTIFICATION_URL, API_KEY);    
    //You then send the message using the sendMessage functions that the library supports    
    pushNotification.sendMessageToUser(MESSAGE, TITLE, LINK_ICON, LINK_WHEN_CLICK, CREATED_AT, UPDATED_AT, USER_RECEIVE_TOKEN);
}

This library supports 3 functions to send a message to the user:

  1. Send to 1 user: sendMessageToUser
  2. Send to a list users: sendMessageToListUser
  3. Send to all users of project: sendMessageToAll