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

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@api.global/typedserver',
version: '4.1.0',
version: '4.1.1',
description: 'A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.'
}

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,