• Home
Name Date Size #Lines LOC

..--

dynamic_codegen/03-May-2024-1,193963

static_codegen/03-May-2024-2,7611,744

.gitignoreD03-May-202429 33

README.mdD03-May-20241.3 KiB5137

package.jsonD03-May-2024241 1312

README.md

1gRPC in 3 minutes (Node.js)
2===========================
3
4PREREQUISITES
5-------------
6
7- `node`: This requires Node 0.12.x or greater.
8
9INSTALL
10-------
11
12   ```sh
13   $ # Get the gRPC repository
14   $ export REPO_ROOT=grpc # REPO root can be any directory of your choice
15   $ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc $REPO_ROOT
16   $ cd $REPO_ROOT
17
18   $ cd examples/node
19   $ npm install
20   ```
21
22TRY IT!
23-------
24
25There are two ways to generate the code needed to work with protocol buffers in Node.js - one approach uses [Protobuf.js](https://github.com/dcodeIO/ProtoBuf.js/) to dynamically generate the code at runtime, the other uses code statically generated using the protocol buffer compiler `protoc`. The examples behave identically, and either server can be used with either client.
26
27 - Run the server
28
29   ```sh
30   $ # from this directory
31   $ node ./dynamic_codegen/greeter_server.js &
32   $ # OR
33   $ node ./static_codegen/greeter_server.js &
34   ```
35
36 - Run the client
37
38   ```sh
39   $ # from this directory
40   $ node ./dynamic_codegen/greeter_client.js
41   $ # OR
42   $ node ./static_codegen/greeter_client.js
43   ```
44
45TUTORIAL
46--------
47You can find a more detailed tutorial in [gRPC Basics: Node.js][]
48
49[Install gRPC Node]:../../src/node
50[gRPC Basics: Node.js]:https://grpc.io/docs/tutorials/basic/node.html
51