-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathapp.controller.ts
More file actions
35 lines (29 loc) · 1007 Bytes
/
app.controller.ts
File metadata and controls
35 lines (29 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Controller, Get, Inject, Param } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import { flush } from '@sentry/nestjs';
import { firstValueFrom } from 'rxjs';
@Controller()
export class AppController {
constructor(@Inject('MATH_SERVICE') private readonly client: ClientProxy) {}
@Get('test-transaction')
testTransaction() {
return { message: 'hello' };
}
@Get('test-microservice-sum')
async testMicroserviceSum() {
const result = await firstValueFrom(this.client.send({ cmd: 'sum' }, { numbers: [1, 2, 3] }));
return { result };
}
@Get('test-microservice-exception/:id')
async testMicroserviceException(@Param('id') id: string) {
return firstValueFrom(this.client.send({ cmd: 'exception' }, { id }));
}
@Get('test-microservice-manual-capture')
async testMicroserviceManualCapture() {
return firstValueFrom(this.client.send({ cmd: 'manual-capture' }, {}));
}
@Get('flush')
async flush() {
await flush();
}
}