| 21 | |
| 22 | @Controller() |
| 23 | export class AppController { |
| 24 | constructor( |
| 25 | @Inject('USE_CLASS_CLIENT') private useClassClient: ClientProxy, |
| 26 | @Inject('USE_FACTORY_CLIENT') private useFactoryClient: ClientProxy, |
| 27 | @Inject('CUSTOM_PROXY_CLIENT') private customClient: ClientProxy, |
| 28 | ) {} |
| 29 | static IS_NOTIFIED = false; |
| 30 | |
| 31 | @Client({ |
| 32 | transport: Transport.TCP, |
| 33 | options: { |
| 34 | tlsOptions: { |
| 35 | ca: [ |
| 36 | fs |
| 37 | .readFileSync(path.join(__dirname, 'ca.cert.pem'), 'utf-8') |
| 38 | .toString(), |
| 39 | ], |
| 40 | }, |
| 41 | }, |
| 42 | }) |
| 43 | client: ClientProxy; |
| 44 | |
| 45 | @Post() |
| 46 | @HttpCode(200) |
| 47 | call(@Query('command') cmd, @Body() data: number[]): Observable<number> { |
| 48 | return this.client.send<number>({ cmd }, data); |
| 49 | } |
| 50 | |
| 51 | @Post('useFactory') |
| 52 | @HttpCode(200) |
| 53 | callWithClientUseFactory( |
| 54 | @Query('command') cmd, |
| 55 | @Body() data: number[], |
| 56 | ): Observable<number> { |
| 57 | return this.useFactoryClient.send<number>({ cmd }, data); |
| 58 | } |
| 59 | |
| 60 | @Post('useClass') |
| 61 | @HttpCode(200) |
| 62 | callWithClientUseClass( |
| 63 | @Query('command') cmd, |
| 64 | @Body() data: number[], |
| 65 | ): Observable<number> { |
| 66 | return this.useClassClient.send<number>({ cmd }, data); |
| 67 | } |
| 68 | |
| 69 | @Post('stream') |
| 70 | @HttpCode(200) |
| 71 | stream(@Body() data: number[]): Observable<number> { |
| 72 | return this.client |
| 73 | .send<number>({ cmd: 'streaming' }, data) |
| 74 | .pipe(scan((a, b) => a + b)); |
| 75 | } |
| 76 | |
| 77 | @Post('concurrent') |
| 78 | @HttpCode(200) |
| 79 | concurrent(@Body() data: number[][]): Promise<boolean> { |
| 80 | const send = async (tab: number[]) => { |
nothing calls this directly
no test coverage detected