Member Junction
    Preparing search index...

    Discovers, initializes, and manages the lifecycle of server extensions.

    Called by MJServer's serve() function during startup. The loader receives the merged extension list (Open App–discovered configs overlaid by host mj.config.cjs serverExtensions[]), uses MJ's ClassFactory to find registered extension classes, and calls Initialize() on each.

    Supports phased loading (pre-auth ahead of JWT middleware, post-auth behind it) and cross-extension service lookup and registration.

    Index

    Constructors

    Accessors

    • get ExtensionCount(): number

      Get the number of currently loaded extensions.

      Returns number

    • get Extensions(): readonly {
          Config: ServerExtensionConfig;
          DriverClass: string;
          Instance: BaseServerExtension;
      }[]

      Get all loaded extension instances for inspection or testing.

      Returns readonly {
          Config: ServerExtensionConfig;
          DriverClass: string;
          Instance: BaseServerExtension;
      }[]

      Read-only array of loaded extensions with their driver class names.

    Methods

    • Run health checks on all loaded extensions.

      Each extension's HealthCheck() is called independently. If one extension's health check throws, it is reported as unhealthy without affecting others.

      Returns Promise<ExtensionHealthResult[]>

      Array of health results, one per loaded extension.

    • Load and initialize all enabled extensions from config.

      Extensions that fail to initialize are logged and skipped — they do not prevent other extensions from loading. This ensures one broken extension doesn't take down the entire server.

      Parameters

      • app: Application

        Express application for route registration.

      • extensionConfigs: ServerExtensionConfig[]

        Array of extension configs from mj.config.cjs.

      • Optionaloptions: LoadExtensionsOptions

        Phased loading, HTTP server, and URL options.

      Returns Promise<void>

    • Notify all loaded extensions across all phases that all extensions have been mounted. Calls OnAllExtensionsMounted(context) on each extension that implements it.

      Parameters

      • Optionaloptions: { httpServer?: Server; publicUrl?: string }

      Returns Promise<void>

    • Shut down all loaded extensions gracefully.

      Called during MJServer's shutdown sequence (SIGTERM/SIGINT). Extensions are shut down in reverse order of loading. Errors during shutdown are logged but do not prevent other extensions from shutting down.

      Returns Promise<void>