Options
All
  • Public
  • Public/Protected
  • All
Menu

Node.js specific utility functions to be used by Coaty agent services.

Hierarchy

  • NodeUtils

Index

Constructors

constructor

Methods

Static getLocalIpV4Address

  • getLocalIpV4Address(networkInterface?: string): string
  • Gets the first IPv4 address of the specified network interface of the local machine. If no network interface name is specified, the first IPv4 address of the first network interface that provides an IPv4 address is returned. Returns undefined if no IPv4 address could be looked up.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    Parameters

    • Optional networkInterface: string

    Returns string

Static getLocalIpV6Address

  • getLocalIpV6Address(networkInterface?: string): string
  • Gets the first IPv6 address of the specified network interface of the local machine. If no network interface name is specified, the first IPv6 address of the first network interface that provides an IPv6 address is returned. Returns undefined if no IPv6 address could be looked up.

    This function can only be used in a server-side environment (Node.js), not in a browser runtime.

    Parameters

    • Optional networkInterface: string

    Returns string

Static handleProcessTermination

  • handleProcessTermination(cleanup?: () => void, cleanupAsync?: () => Promise<any>): void
  • Perform synchronous and asynchronous cleanup of allocated resources (e.g. file descriptors, handles, DB connections, etc.) before shutting down the Node.js process.

    Parameters

    • Optional cleanup: () => void

      callback function for synchronous cleanup (optional)

        • (): void
        • Returns void

    • Optional cleanupAsync: () => Promise<any>

      callback function for asynchronous cleanup (optional)

        • (): Promise<any>
        • Returns Promise<any>

    Returns void

Static logCommunicationState

  • logCommunicationState(container: Container): void
  • Log changes in online/offline communication state (i.e. agent connection to Coaty broker) to the console.

    Parameters

    Returns void

Static logError

  • logError(error: any, message?: string, isoDateString?: string): void
  • Log the given error to console, also providing the logging date.

    Parameters

    • error: any

      error

    • Optional message: string

      an extra message (optional)

    • Optional isoDateString: string

      date string in ISO format or unspecified to use current data (optional)

    Returns void

Static logEvent

  • logEvent(message: string, eventName?: string, eventDirection?: "In" | "Out"): void
  • Log the given event to console, also providing the logging date.

    Parameters

    • message: string

      message to log

    • Optional eventName: string

      name of event to log (optional)

    • eventDirection: "In" | "Out" = "In"

      direction of event to log (in or out)

    Returns void

Static logInfo

  • logInfo(message: string, isoDateString?: string): void
  • Log the given informational message to console, also providing the logging date.

    Parameters

    • message: string

      informational message to log

    • Optional isoDateString: string

      date string in ISO format or unspecified to use current data (optional)

    Returns void

Static provideConfiguration

  • Provide a Configuration from the specified local JSON or JS file.

    The value of this option must be the relative or absolute filename of a JSON config file or a CommonJS module file that exports a Configuration object.

    If unspecified the default file looked up is app.config.js, then app.config.json in the current working directory of the server process.

    This option can only be used in a server-side environment (Node.js), not in a browser runtime.

    Parameters

    • localConfigFile: string = "app.config"

      a local configuration file

    Returns Configuration

Static provideConfigurationAsync

  • provideConfigurationAsync(configurationUrl: string): Promise<Configuration>
  • Asynchrounously provides a Configuration from the given Url expecting a Configuration object in JSON format.

    This option can only be used in a server-side environment (Node.js), not in a browser runtime.

    Parameters

    • configurationUrl: string

      a Url to load the configuration from

    Returns Promise<Configuration>

Generated using TypeDoc