diff --git a/app/__tests__/base-app.module.spec.ts b/app/__tests__/base-app.module.spec.ts index 24f099c..006d23f 100644 --- a/app/__tests__/base-app.module.spec.ts +++ b/app/__tests__/base-app.module.spec.ts @@ -28,6 +28,17 @@ describe('BaseNraAppModule', () => { expect(result.controllers).toContain(AppController); }); + it('registers project controllers after AppController', () => { + class ProjectController { } + const result = BaseNraAppModule.forRoot({ + entitiesModule: FakeEntitiesModule, + yemotHandlerService: FakeYemotHandlerService as any, + controllers: [ProjectController], + }); + + expect(result.controllers).toEqual([AppController, ProjectController]); + }); + it('includes AppService in providers', () => { const result = BaseNraAppModule.forRoot({ entitiesModule: FakeEntitiesModule, diff --git a/app/base-app.module.ts b/app/base-app.module.ts index b65983d..fa3dc63 100644 --- a/app/base-app.module.ts +++ b/app/base-app.module.ts @@ -28,6 +28,8 @@ export interface BaseNraAppModuleOptions { throttlerLimit?: number; /** Project-specific async job handlers, registered alongside the shared ones. */ jobHandlers?: Type[]; + /** Project-specific controllers, registered next to the shared `AppController`. */ + controllers?: Type[]; /** MCP tools; when given, the app serves them at `/mcp`. */ mcpTools?: Type[]; /** MCP server instructions: what the app is and how its tools fit together. */ @@ -59,7 +61,7 @@ export class BaseNraAppModule { YemotModule.register(options.yemotHandlerService), ...(options.mcpTools?.length ? [McpModule.forRoot({ tools: options.mcpTools, instructions: options.mcpInstructions, prompts: options.mcpPrompts, consent: options.mcpConsent })] : []), ], - controllers: [AppController], + controllers: [AppController, ...(options.controllers ?? [])], providers: [ AppService, {