Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cognitev/pubsub-gcp-js
a wrapping package around GCP pubsub package to provide a more convenient, abstract functionalities
https://github.com/cognitev/pubsub-gcp-js
events gcp javascript nodejs pubsub
Last synced: about 9 hours ago
JSON representation
a wrapping package around GCP pubsub package to provide a more convenient, abstract functionalities
- Host: GitHub
- URL: https://github.com/cognitev/pubsub-gcp-js
- Owner: cognitev
- License: agpl-3.0
- Created: 2020-06-17T14:47:06.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-02T22:07:46.000Z (over 2 years ago)
- Last Synced: 2024-12-12T01:48:31.974Z (29 days ago)
- Topics: events, gcp, javascript, nodejs, pubsub
- Language: JavaScript
- Size: 152 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pubsub-gcp-js
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
[![Build Status:](https://github.com/cognitev//pubsub-gcp-js/workflows/Node/badge.svg)](https://github.com/cognitev/pubsub-gcp-js/actions)Wrapping package around gcp pubsub package to provide a more conveniet, abstract functionalities
## how to install
```shell
npm i --save pubsub-gcp
```## how to use
- first step is to initialize pubsub client with your account credentialis
```js
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:
```js
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