Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

pubsub-subscriber

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pubsub-subscriber

An opinionated GCP Pub/Sub subscriber we use here at [Namshi](https://github.com/namshi).

latest
Source
npmnpm
Version
1.4.4
Version published
Weekly downloads
0
-100%
Maintainers
4
Weekly downloads
 
Created
Source

pubsub-subscriber

An opinionated GCP Pub/Sub subscriber we use here at Namshi.

Usage

let {subscribe} = require('pubsub-subscriber')

// name of the topic you want to listen to
let topic = "my_topic" 

// name of your subscription, will be created automagically
let subscription = "my_topic_send_email"

// function that processes the message:
// payload will be the JSON parsed.
// 
// Return to ack, throw an exception to nack.
async function onMessage(payload, options) {
    if (payload.ok) {
        return
    }
    
    // options.message - the original message object from the pubsub SDK
    // options.topic_name - the topic you've subscribed to

    throw new Error("I f'ed up")
}

subscribe(topic, subscription, onMessage)

That's it!

Keywords

gcp

FAQs

Package last updated on 16 Feb 2023

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