@@ -39,9 +39,17 @@ const server = new DaprServer(serverHost, serverPort, daprHost, daprPort, Commun
3939const client = new DaprClient (daprHost, daprPort, CommunicationProtocolEnum .GRPC );
4040```
4141
42- ## Running using HTTP or gRPC
42+ ## Running
4343
44- By default, the example uses HTTP. To run:
44+ To run the examples, you can use two different protocols to interact with the Dapr sidecar: HTTP (default) or gRPC.
45+
46+ ### Using HTTP (default)
47+
48+ ``` javascript
49+ import { DaprClient , DaprServer } from " dapr-client" ;
50+ const client = new DaprClient (daprHost, daprPort);
51+ const server = new DaprServer (appHost, appPort, daprHost, daprPort);
52+ ```
4553
4654``` bash
4755# Using dapr run
@@ -51,23 +59,23 @@ dapr run --app-id <example-sdk> --app-port 50051 --app-protocol http npm run sta
5159npm run start:dapr-http
5260```
5361
54- To use gRPC instead:
55-
56- - Add ` CommunicationProtocolEnum.GRPC ` to the DaprClient object creation:
62+ ### Using gRPC
5763
58- ``` javascript
59- const client = new DaprClient (daprHost, process .env .DAPR_HTTP_PORT , CommunicationProtocolEnum .GRPC );
60- ```
64+ Since HTTP is the default, you will have to adapt the communication protocol to use gRPC. You can do this by passing an extra argument to the client or server constructor.
6165
62- - To run:
66+ ``` javascript
67+ import { DaprClient , DaprServer , CommunicationProtocol } from " dapr-client" ;
68+ const client = new DaprClient (daprHost, daprPort, CommunicationProtocol .GRPC );
69+ const server = new DaprServer (appHost, appPort, daprHost, daprPort, CommunicationProtocol .GRPC );
70+ ```
6371
64- ``` bash
65- # Using dapr run
66- dapr run --app-id < example-sdk> --app-port 50051 --app-protocol grpc npm run start
72+ ``` bash
73+ # Using dapr run
74+ dapr run --app-id < example-sdk> --app-port 50051 --app-protocol grpc npm run start
6775
68- # or, using npm script
69- npm run start:dapr-grpc
70- ```
76+ # or, using npm script
77+ npm run start:dapr-grpc
78+ ```
7179
7280### DaprClient Library
7381A library that provides methods for how an application communicates with the Dapr sidecar.
0 commit comments