monorepo-microservice-rbac/apps/services
2023-09-05 15:07:15 +08:00
..
aorta first commit 2023-08-27 14:37:59 +08:00
cert feat: 上传全部影像 2023-09-01 16:36:58 +08:00
dicom feat: 下载dicom 2023-09-05 15:07:15 +08:00
dmp feat: 下载dicom 2023-09-05 15:07:15 +08:00
logger first commit 2023-08-27 14:37:59 +08:00
readme.md first commit 2023-08-27 14:37:59 +08:00

发布订阅EventPattern

@MessagePattern: 基于rpc比较喜欢用一个菠萝一个坑

// 网关
@Get('/hello')
async getHello(): Promise<any> {
  const pattern = { cmd: 'sum' };
  const payload = [1, 2];
  // this.client.emit(pattern,payload)没有返回值
  const it = await this.client.send<number[]>(pattern, payload);
  return `收到返回值: ${it}`;
}

// 服务
@EventPattern({ cmd: 'sum' })
sum(data: number[]): number {
  return (data || []).reduce((a, b) => a + b);
}