nestjs-pubsub-health-check

Nest module, that checks health of PubSub module

Usage no npm install needed!

<script type="module">
  import nestjsPubsubHealthCheck from 'https://cdn.skypack.dev/nestjs-pubsub-health-check';
</script>

README

nestjs-pubsub-health-check

Deploy Coverage Status

Nest module, that checks health of PubSub module

How it works

Module uses @nestjs/terminus health-check, and this module intended to be used with it. Module tries to check if topic exists (by calling exists function on each passed topic). Also, you need to grant roles/pubsub.viewer role to your application, (or any role that contains this), to access topic info.

Usage

Installation:

npm i nestjs-pubsub-health-check
@Module({
   imports: [
     PubSubHealthCheckModule.forRootAsync({
       inject: [PubSubService],
       useFactory: (ps: PubSubService) => ({
          topics: [ps.topic],
          timeout: 5000, // optional
          healthCheckKey: 'pubsub' // optional
       }),
     ),
     SomeModule,
   ],
 })
 export class AppModule {}

And in you HealthCheck module just call

    // this.health - HealthCheckService from @nestjs/termius
    this.health.check([
        async () => this.pubSubHealthCheckModule.pingCheck(),
    ]);

Bootstrapped with: create-ts-lib-gh

This project is Mit Licensed.