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 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-fcm-hero

v0.1.0

Published

Firebase fcm easy customizable service

Readme

Build Status Coverage Status

node-fcm-hero

FCM interface with super powers. Send push notifications to android/ios in a simple way

Installation

How it works

To use this lib, you have to import:

const fcm          = require('node-fcm-hero');
const { firebase } = require("./your.config.file");
const push         = fcm(config);

The config file must have this format:

{
  firebase: {
    cert: "/route/to/firebase-adminsdk.json",
    url : "https://your-project.firebaseio.com"
  }
}

The cert param has to be the path to yor firebase json file.

If you already have an initializated instance of firebase-admin module, you can pass directly the messaging function to initialize the node-fcm-hero. Ie:

const fcm          = require('node-fcm-hero');
const { firebase } = require("./your.config.file");
const push         = fcm(config, myFirebaseAdmin.messaging());

Send notification

To send a push notification you will need to call the send method. Ie:

const event = {
  token   : '',
  type    : '',
  payload : '',
  pushType: ''
}
push.send(event)
  .then(res => console.log(res))
  .catch(err => console.log(err));

Push notification type

You can set the pushType attribute of the event to define the kind of template to send. This pushType must be a string with the name of one of the custom templates you initialize to the project.

If you do not set any template or it didn't find in the type in the templates folder, the notification will fail.

You can make this work like an event Redux flow, passing the type and defining a template file per event you want to push.

If the event type don't macht with any template, the node-fcm-hero will return a unsuccess json object:

{
  success: 0,
  error  : 'No template found for this event'
}

Custom templates

You can override the default types and templates for your own, setting in the firebase config object a templatesPath field with the string to the path.

{
  firebase: {
    cert: "/route/to/firebase-adminsdk.json",
    url : "https://your-project.firebaseio.com",
    templatesPath: "/path/to/templates"
  }
}

You can find examples of the templates format under the folder 'exampleTemplates'.

Event listeners

node-fcm-hero has a default events pre configured to help you to subscribe to listeners depending of this default events.

This is the list of the default events:

push.events :

.UNINSTALLED      
.RENEW_CREDENTIALS
.FIREBASE_ERROR   
.ERROR            
.SUCCESS          

To subscribe and catch some of this events, you need to add a callback funtion asociated to the event:

push.on(push.events.UNINSTALLED, callback1);
push.on(push.events.ERROR, callback2);
push.on(push.events.RENEW_CREDENTIALS, callback3);

UNINSTALLED event

Will return every single token marked as app uninstalled after the called send function.

Error handling

If any error happends, the node-fcm-hero will return a json object with the success field equal to 0. Also, it will notify to the on error listeners.

Test

To make the integration test work, you need to provide your own instance of firebase admin messaging or set your configuration file with the route to your firebase-adminsdk.json. Also you need to you provide at least one working firebase token and one uninstalled to cover all the best scenarios. After that, delete the .skip of the nodeFcmHero.e2e.test.js

Sorry for this, but i don't want to see how my phone 💥💥💥

Powered by: Lingbe App