Version: v1
Installation
#
Requirements- Node.js version >= 12.13.0 or above (which can be checked by running node -v). You can use nvm for managing multiple Node versions on a single machine installed
#
Install#
From NPM#
From Github Package RepositoryWe also publish to Github Package Repository as @deliveryhero/pubsub
. To install from there, first add this to your .npmrc
:
And then install the package.
#
Project structureThe framework expects that you've created a pubsub directory in your project with the following structure:
#
Required Environment VariablesThe framework expects the following environment variables. They can be added to the .env
file or passed through CLI args.
.env
CLI Argument | Env Variable | Description |
---|---|---|
root-dir | PUBSUB_ROOT_DIR | must be the path to your project's pubsub directory. This module only works with .js files, so if you are writing your code in typescript, you must set this variable to the pubsub directory in your project's build directory. |
google-application-credentials | GOOGLE_APPLICATION_CREDENTIALS | see https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account to generate this |
project-id | GOOGLE_CLOUD_PUB_SUB_PROJECT_ID | name of the project in Google Cloud Platform |
server-port | PUBSUB_SERVER_PORT | PORT at which the pubsub should run the server at |
health-server | PUBSUB_HEALTH_SERVER | If value assigned is true this would run a server showing health state and return 500 if not healthy |
|
#
What next?- Once the directory structure has been defined and environment variables set
- Then you can create subscriptions and topics
- Initialize your database connection, define project-level subscription defaults, and register subscriptions in the Subscription Service.
- After a service has been created, use the CLI to start the subscriptions server.