Skip to content

a wrapping package around GCP pubsub package to provide a more convenient, abstract functionalities

License

Notifications You must be signed in to change notification settings

cognitev/pubsub-gcp-js

Repository files navigation

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

About

a wrapping package around GCP pubsub package to provide a more convenient, abstract functionalities

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published