BSB Node.js Type Definitions
    Preparing search index...

    Class BSBConfig<ReferencedConfig>Abstract

    The type of config for the plugin Abstract class representing the configuration for the Better Service Base.

    Type Parameters

    Index

    Constructors

    Properties

    config: BSBConfigPropertyTypeSafe<BSBConfigResolvedConfig<ReferencedConfig>>
    appId: string = "tbd"

    The unique app id of the app that is running

    mode: DEBUG_MODE = "development"

    The mode the app is running in

    production (production mode - no debug)
    
    production-debug (production mode - debug)
    
    development (development mode - debug)
    
    cwd: string

    The current working directory of the app

    packageCwd: string

    The current working directory of the plugin

    pluginCwd: string

    The current working directory of the service

    pluginName: string

    The name of the plugin This is also the mapped name, or the name defined in the config rather than it's original defined name

    region?: string

    The deployment region for resource context

    Methods

    • Run lifecycle method for configuration plugins.

      This method is inherited from the base plugin class but is not used by configuration plugins. Configuration plugins are initialized during the init phase and provide configuration data to other plugins. They do not require a separate run phase.

      Returns void

      void

      Configuration plugins are typically disposed after all other plugins have been initialized to free up memory, as configuration data is cached by individual plugins. Therefore, this method intentionally performs no operation.

      // Configuration plugins do not need to implement run()
      // The base class provides this no-op implementation
      export class MyConfigPlugin extends BSBConfig {
      // No run() override needed
      }
    • Returns the observable plugins configuration (unified logging, metrics, tracing).

      Parameters

      Returns Promise<Record<string, ObservableConfig>>

      Promise resolving to an object containing the observable configuration for each plugin.

    • Returns the events plugins configuration.

      Parameters

      Returns Promise<Record<string, EventsConfig>>

      Promise resolving to an object containing the events configuration for each plugin.

    • Returns the service plugins configuration.

      Parameters

      Returns Promise<Record<string, PluginDefinition>>

      Promise resolving to an object containing the configuration for each plugin.

    • Returns a mapped plugin name and whether the plugin is enabled or not

      Parameters

      Returns Promise<{ name: string; enabled: boolean }>

      string of the plugin name and if it is enabled or not

    • Returns the configuration for a specific plugin.

      Parameters

      • obs: Observable
      • pluginType: PluginType
      • plugin: string

        The name of the plugin to retrieve the configuration for.

      Returns Promise<object | null>

      Promise resolving to the configuration object for the specified plugin, or null if the plugin is not found.

    • Dispose Optional function to be called when the plugin is being disposed

      Returns void

      dispose?(): void; //to not use it
      
      dispose() { your code here };
      
    • Init Optional function to be called when the plugin is being initialized Can be sync or async

      Parameters

      • obs: Observable

        Observable context with logging, metrics, and trace information

      Returns void | Promise<void>

      v9 BREAKING CHANGE: Now requires Observable instead of DTrace. Observable provides unified access to logging, metrics, and tracing with automatic context propagation.

      async init(obs: Observable) {
      obs.log.info("Initializing plugin");
      // Set attributes for all child operations
      const withVersion = obs.setAttribute("plugin.version", "1.0.0");
      }