1.1.1 • Published 3 years ago

@tricky-max/nestjs-pubsub-health-check v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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 @tricky-max/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.