2.0.0 • Published 5 years ago

pubsub-gcp v2.0.0

Weekly downloads
5
License
AGPL v3
Repository
github
Last release
5 years ago

pubsub-gcp-js

License: AGPL v3 Build Status:

Wrapping package around gcp pubsub package to provide a more conveniet, abstract functionalities

how to install

npm i --save pubsub-gcp

how to use

  • first step is to initialize pubsub client with your account credentialis
const pubsub = require('pubsub-gcp');
const privateKey = 'gcp_private_key';
const email = 'account_email';
const projectId = 'target_gcp_project';
await pubsub.initClient(projectId, email, privateKey);

here you have 3 params that you get from your account on GCP to authorize the package to publish messages on your behalf.

Note: if you pass any of those params as null or did not pass any of them at all, they will replaced by the following envs respectively:

  • GCLOUD_PROJECT_ID_PUBSUB
  • GCLOUD_CLIENT_EMAIL
  • GCLOUD_PRIVATE_KEY

  • to publish a message on any of your topics:

await pubsub.publish({'random': 'message'}, 't2'); // will return message id on topic

Note: you can pass a third argument create_topic as true to auto create the topic then publish the message