The most basic and unopinionated implementation of GCP PubSub transport for NestJS microservices
// readme
nestjs-gcp-pubsub
The most basic and unopinionated implementation of GCP PubSub transport for NestJS microservices.
The publisher should not care who will handle the event and by which pattern, it only knows the topic. So, no hardcoded patterns in PubSub messages: on publishing events pass the topic-name as a pattern, and on subscription pass topic-name/subscription-name string as a pattern.
ack() is called automatically when no errors are thrown while handling, otherwise nack() is called.
No topics and subscriptions are created automatically. Because we care about security.
install
npm i nestjs-gcp-pubsub @google-cloud/pubsub
configure
setup server:
import { GCPPubSubStrategy } from 'nestjs-gcp-pubsub';
NestFactory.createMicroservice(
AppModule,
{
strategy: new GCPPubSubStrategy({
// Props of { ClientConfig } from '@google-cloud/pubsub'
projectId: 'my-project-id',
// Optional deserializer, please see
// implementation in the sources.
// Default…