Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(microservices): generate service method in lower and uppercase #9052

Merged
merged 1 commit into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions integration/microservices/e2e/sum-grpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ describe('GRPC transport', () => {
);
});

it(`GRPC Sending and Receiving HTTP POST`, () => {
return request(server)
it(`GRPC Sending and Receiving HTTP POST`, async () => {
await request(server)
.post('/sum')
.send([1, 2, 3, 4, 5])
.expect(200, { result: 15 });

await request(server)
.post('/upperMethod/sum')
.send([1, 2, 3, 4, 5])
.expect(200, { result: 15 });
});

it(`GRPC Sending and Receiving HTTP POST (multiple proto)`, async () => {
Expand Down
8 changes: 8 additions & 0 deletions integration/microservices/src/grpc/grpc.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ export class GrpcController {
return svc.sum({ data });
}

// Test that getService generate both lower and uppercase method
@Post('upperMethod/sum')
@HttpCode(200)
callWithOptions(@Body() data: number[]): Observable<number> {
const svc = this.client.getService<any>('Math');
return svc.Sum({ data });
}

@GrpcMethod('Math')
async sum({ data }: { data: number[] }): Promise<any> {
return of({
Expand Down
3 changes: 1 addition & 2 deletions packages/microservices/client/client-grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ export class ClientGrpcProxy extends ClientProxy implements ClientGrpc {
const grpcService = {} as T;

protoMethods.forEach(m => {
const key = m[0].toLowerCase() + m.slice(1, m.length);
grpcService[key] = this.createServiceMethod(grpcClient, m);
grpcService[m] = this.createServiceMethod(grpcClient, m);
});
return grpcService;
}
Expand Down