AbstractDefault lifecycle phase for this extension when unspecified in configuration.
Defaults to 'pre-auth' for backwards compatibility.
AbstractHealthHealth 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.
Supports both modern context-based signature:
Initialize(context: ServerExtensionInitContext): Promise<ExtensionInitResult>
and legacy 2-argument signature:
Initialize(app: Application, config: ServerExtensionConfig): Promise<ExtensionInitResult>
Optionalconfig: ServerExtensionConfigOptionalOnOptional lifecycle hook called after ALL extensions have been mounted across all phases. Ideal for cross-extension service wiring (e.g. connecting a webhook router to a telephony service).
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[](Open App packages + host overlay)@RegisterClass(BaseServerExtension, driverClass)ClassFactory.CreateInstance()Initialize(context)(or legacyInitialize(app, config)) — extension registers routesOnAllExtensionsMounted(context)if implementedHealthCheck()calls for monitoringShutdown()for cleanup