Skip to content

Commit d8af357

Browse files
committed
update to "running" section per Xavier
Signed-off-by: Hannah Hunter <[email protected]>
1 parent 961cd01 commit d8af357

File tree

1 file changed

+23
-15
lines changed
  • daprdocs/content/en/js-sdk-docs/js-client

1 file changed

+23
-15
lines changed

daprdocs/content/en/js-sdk-docs/js-client/_index.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,17 @@ const server = new DaprServer(serverHost, serverPort, daprHost, daprPort, Commun
3939
const 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
5159
npm 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
7381
A library that provides methods for how an application communicates with the Dapr sidecar.

0 commit comments

Comments
 (0)