question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support grpc-js for the non generate_package_definition output

See original GitHub issue

Hello GRPC node team!

Currently we use the latest grpc-tools and ts-protoc-gen for generating js/ts code for the GRPC models/services.

We use the simple grpc-tools output without the generate_package_definition option. In the same way as provided here https://github.com/grpc/grpc/tree/master/examples/node/static_codegen

import { credentials } from "grpc";
import { MyServiceClient } from "my_service_grpc_pb";
import { CreateUserRequest } from "my_service_pb";

const client = new MyServiceClient("url", credentials.createInsecure());
client.createUser(new CreateUserRequest(), (error, value) => {});

one more example here https://github.com/agreatfool/grpc_tools_node_protoc_ts/blob/master/examples/src/grpc/client.ts

Pros:

Cons:

  • this approach requires to use the “grpc” node library which will be deprecated soon

The question is there any plans to support “grpc-js” for this GRPC output option?

Also please correct me if I’m wrong, but it sounds like that PR proto-loader: Add TypeScript generator https://github.com/grpc/grpc-node/pull/1474 doesn’t have this feature at all

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
murgatroid99commented, Aug 12, 2020

The grpc-tools library accepts the argument --grpc_js, which should do what you are asking for.

The linked PR for the @grpc/proto-loader library has the --grpcLib option, which can be used for the same effect.

0reactions
murgatroid99commented, Aug 13, 2020

No, I wrote that section of the README before the --grpc_js option was added. The --grpc_js option only does something if you don’t use the --generate_package_definition option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basics tutorial | Node - gRPC
This tutorial provides a basic Node.js programmer's introduction to working with gRPC. By walking through this example you'll learn how to:.
Read more >
gRPC service in Node.js: Tutorial, Examples and Best practices
It enables us to create gRPC service in the Nodejs runtime. @grpc/proto-loader: A utility package for loading .proto files for use with gRPC...
Read more >
The Weird World of gRPC Tooling for Node.js, Part 1 - Medium
grpc -tools provides a plugin to protoc that allows it to generate JavaScript client stubs and server skeletons that implement a normal object ......
Read more >
Tutorial: How to Build Your First Node.js gRPC API - Trend Micro
While not mandatory, JavaScript knowledge is also quite helpful. ... You create the package definitions and the gRPC object in the same way....
Read more >
How to Easily use GRPC and Protocol Buffers with NodeJS
Modify the package.json file · Defining the Protocol Buffer · Creating the GRPC Server · Creating the GRPC Client · Running The Server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found