fix(classes.typedserver): Instantiate and register DevToolsController only when injectReload is enabled; compile ControllerRegistry routes after registration

This commit is contained in:
2025-12-02 21:03:57 +00:00
parent dce2e926e4
commit c25daba1c1
3 changed files with 19 additions and 6 deletions

View File

@@ -206,10 +206,12 @@ export class TypedServer {
}
// Initialize decorated controllers
this.devToolsController = new DevToolsController({
getLastReload: () => this.lastReload,
getEnded: () => this.ended,
});
if (this.options.injectReload) {
this.devToolsController = new DevToolsController({
getLastReload: () => this.lastReload,
getEnded: () => this.ended,
});
}
this.typedRequestController = new TypedRequestController(this.typedrouter);
@@ -227,10 +229,15 @@ export class TypedServer {
});
// Register controllers with SmartServe's ControllerRegistry
plugins.smartserve.ControllerRegistry.registerInstance(this.devToolsController);
if (this.options.injectReload) {
plugins.smartserve.ControllerRegistry.registerInstance(this.devToolsController);
}
plugins.smartserve.ControllerRegistry.registerInstance(this.typedRequestController);
plugins.smartserve.ControllerRegistry.registerInstance(this.builtInRoutesController);
// Compile routes for fast matching
plugins.smartserve.ControllerRegistry.compileRoutes();
// Build SmartServe options
const smartServeOptions: plugins.smartserve.ISmartServeOptions = {
port,