New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

throttle-messages-firebase

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

throttle-messages-firebase

Send messages throttled either as emails or notifications

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

throttled-messages-firebase

Enables you to send notifications and emails throttled from firebase with simple Cloud Function implementation.

General usage

To queue the messages use:

const throttledMessages = require('../functions/npm-throttle-messages-firebase')
throttledMessages.queueMessage(admin, delay, type, address, payload, id)
    .then(msgKey => {
        console.log('message queued with key', msgKey)
        process.exit();
})

It basically just creates an entry in Realtime Database under message_queue to be handled by cron. queueMessage returns the id of the queued message and if you pass it as the id parameter next time you queue the message, it replaces the first one. Essencially throttling the message.

Cloud functions

Here's an example of how to implement the Cloud Functions

export const messageQueueOnWrite = functions.database.ref('message_queue/{messageId}').onWrite((change, context) => throttledMessages.messageCreated(admin, change, context))
export const sendWithCron = functions.https.onRequest((req, res) => throttledMessages.cronCallback(admin, req, res))

Build process uses TypeScript

License

CC BY-SA

This project was brought to you by Makeable ApS

FAQs

Package last updated on 06 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts