AbstractAbstractHealthHealth check for this extension.
Called by MJServer's aggregate /health/extensions endpoint.
Should be fast (< 100ms) and non-blocking.
Health status including whether the extension is operational.
AbstractInitializeInitialize the extension. Called once during MJServer startup.
Use this to register Express routes, set up WebSocket handlers, initialize connections, and prepare the extension for operation.
The Express application instance to register routes on.
Routes should be registered under config.RootPath.
Extension-specific configuration from mj.config.cjs.
The Settings object contains extension-specific config.
A result indicating whether initialization succeeded. On failure, the extension is skipped but other extensions still load.
OptionalOnOptional: Called when configuration changes at runtime.
Not all extensions need to support hot-reloading of configuration. Override this method if your extension can dynamically adjust its behavior without a full restart.
The updated configuration from mj.config.cjs.
AbstractShutdownGraceful shutdown. Called when MJServer is shutting down (SIGTERM/SIGINT).
Clean up connections, drain in-flight requests, close WebSocket connections, and release any resources held by the extension.
This method should complete within a reasonable timeout (< 5 seconds). MJServer enforces a 10-second forced shutdown if graceful shutdown hangs.
Abstract base class for MJServer extensions.
Extensions are discovered via
@RegisterClass(BaseServerExtension, 'DriverClassName')and matched to config entries inmj.config.cjsby theirDriverClassname.MJServer calls
Initialize()during startup, passing the Express app so the extension can register its own routes, middleware, and lifecycle hooks.Lifecycle
serverExtensions[]frommj.config.cjs@RegisterClass(BaseServerExtension, driverClass)ClassFactory.CreateInstance()Initialize(app, config)— extension registers routesHealthCheck()calls for monitoringShutdown()for cleanupUsage
Auth Middleware
Extensions handle their own authentication by default. If you want to leverage MJServer's built-in auth middleware, import it from
@memberjunction/server:This is opt-in — extensions like Slack/Teams use platform-specific auth (signature verification, Bot Framework JWT) instead.