How to use the @nestjs/terminus.ConnectionNotFoundError function in @nestjs/terminus

To help you get started, we’ve selected a few @nestjs/terminus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github juicycleff / ultimate-backend / libs / core / src / heath-indicators / mongo.health.ts View on Github external
public async pingCheck(
    key: string,
    options: MongoPingCheckSettings = {},
  ): Promise {
    let isHealthy = false;
    this.checkDependantPackages();

    const connection: MongoClient = options.connection || this.getContextConnection();
    const timeout = options.timeout || 1000;

    if (!connection) {
      throw new ConnectionNotFoundError(
        this.getStatus(key, isHealthy, {
          message: 'Connection provider not found in application context',
        }),
      );
    }

    try {
      await this.pingDb(connection, timeout);
      isHealthy = true;
    } catch (err) {
      if (err instanceof PromiseTimeoutError) {
        throw new TimeoutError(
          timeout,
          this.getStatus(key, isHealthy, {
            message: `timeout of ${timeout}ms exceeded`,
          }),

@nestjs/terminus

Terminus integration provides readiness/liveness health checks for NestJS.

MIT
Latest version published 5 months ago

Package Health Score

86 / 100
Full package analysis

Similar packages