proactive-deps
    Preparing search index...

    Interface DependencyCheckOptions

    Configuration options defining a dependency to be monitored. DependencyCheckOptions

    const monitor = new DependencyMonitor();

    const myDependency: DependencyCheckOptions = {
    name: 'Some Database',
    description: 'Database connection check',
    impact: 'Database data will be unavailable.',
    skip: process.env.NODE_ENV === 'dev', // skip in dev environment
    contact: {
    team: 'Dev Team',
    slack: '#dev-team-channel',
    },
    cacheDurationMs: 30000, // override cache duration to 30 seconds
    refreshThresholdMs: 10000, // override refresh threshold to 10 seconds
    check: async () => {
    // Perform some check (e.g., ping a database)
    return SUCCESS_STATUS_CODE;
    },
    checkDetails: {
    type: 'database',
    server: 'localhost',
    database: 'mydb',
    dbType: 'mysql',
    }
    };

    monitor.register(myDependency);
    interface DependencyCheckOptions {
        cacheDurationMs?: number;
        checkDetails?:
            | DatabaseCheckDetails
            | RestCheckDetails
            | SoapCheckDetails
            | GenericCheckDetails;
        contact?: { [key: string]: string };
        description: string;
        impact: string;
        name: string;
        refreshThresholdMs?: number;
        skip?: boolean;
        check(): Promise<DependencyCheckResult>;
    }
    Index

    Properties

    cacheDurationMs?: number

    Optional override duration (in milliseconds) to cache this dependency checks result.

    const myDependency: DependencyCheckOptions = {
    ...
    cacheDurationMs: 30000, // override cache duration to 30 seconds
    };
    checkDetails?:
        | DatabaseCheckDetails
        | RestCheckDetails
        | SoapCheckDetails
        | GenericCheckDetails

    Optional details about what is being checked, and how.

    const checkDetails: DatabaseCheckDetails = {
    type: 'database',
    server: 'localhost',
    database: 'mydb',
    dbType: 'mysql',
    };
    const myDependency: DependencyCheckOptions = {
    ...
    checkDetails,
    };
    contact?: { [key: string]: string }

    Optional contact information for the dependency. Can contain any number of custom properties.

    const myDependency: DependencyCheckOptions = {
    ...
    contact: {
    team: 'Dev Team',
    slack: '#dev-team-channel',
    },
    };
    description: string

    A description of the dependency.

    const myDependency: DependencyCheckOptions = {
    ...
    description: 'Database used for very important data.',
    };
    impact: string

    The impact of the dependency on the system, should it go down.

    const myDependency: DependencyCheckOptions = {
    ...
    impact: 'Important data will not be available and specific things wont work.',
    };
    name: string

    The name of the dependency.

    const myDependency: DependencyCheckOptions = {
    name: 'Very Important Database',
    ...
    };
    refreshThresholdMs?: number

    Optional override duration (in milliseconds) to refresh this dependency checks result.

    const myDependency: DependencyCheckOptions = {
    ...
    refreshThresholdMs: 10000, // override refresh threshold to 10 seconds
    };
    skip?: boolean

    Optional flag to skip the check. Useful for skipping checks in some environments.

    false
    
    const myDependency: DependencyCheckOptions = {
    ...
    skip: process.env.NODE_ENV === 'dev', // skip in dev environment
    };

    Methods

    • A function that performs the dependency check and returns a result.

      Returns Promise<DependencyCheckResult>

      • A promise that resolves to the result of the check.
      const myDependency: DependencyCheckOptions = {
      ...
      check: async () => {
      // Perform the check (e.g., ping the database)
      try {
      await database.ping();
      return SUCCESS_STATUS_CODE;
      } catch (error) {
      return {
      code: ERROR_STATUS_CODE,
      error: error,
      errorMessage: 'Database not reachable',
      };
      }
      };
      };