|
1 | | -import { Module } from '@nestjs/common'; |
| 1 | +import { DynamicModule } from '@nestjs/common'; |
2 | 2 | import { AiModule } from '../ai'; |
3 | 3 | import { RunModule } from '../run'; |
4 | 4 | import { ChatHelpers } from './chat.helpers'; |
5 | 5 | import { ChatService } from './chat.service'; |
6 | 6 | import { SocketModule } from '@nestjs/websockets/socket-module'; |
7 | 7 | import { ChatController } from './chat.controller'; |
| 8 | +import { createControllerWithPrefix } from '../../utils/controllers'; |
8 | 9 |
|
9 | 10 | export const sharedServices = [ChatHelpers, ChatService]; |
10 | 11 |
|
11 | | -@Module({ |
12 | | - imports: [SocketModule, AiModule, RunModule], |
13 | | - providers: [...sharedServices], |
14 | | - controllers: [ChatController], |
15 | | - exports: [...sharedServices], |
16 | | -}) |
17 | | -export class ChatModule {} |
| 12 | +export class ChatModule { |
| 13 | + static register(prefix: string): DynamicModule { |
| 14 | + return { |
| 15 | + module: ChatModule, |
| 16 | + imports: [SocketModule, AiModule, RunModule], |
| 17 | + providers: [ |
| 18 | + ...sharedServices, |
| 19 | + { |
| 20 | + provide: 'PREFIX', |
| 21 | + useValue: prefix, |
| 22 | + }, |
| 23 | + ], |
| 24 | + controllers: [createControllerWithPrefix(ChatController, prefix)], |
| 25 | + exports: [...sharedServices], |
| 26 | + }; |
| 27 | + } |
| 28 | +} |
0 commit comments