Skip to content

Commit 0dc910f

Browse files
committed
Additional changes
1 parent c6b7922 commit 0dc910f

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

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

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ Install the SDK with npm:
1919
npm i @dapr/js-sdk
2020
```
2121

22-
Import the libraries for the the given protocol:
23-
22+
Import the libraries for the the given protocol:
2423
```javascript
2524
const daprHost = "127.0.0.1"; // Dapr Sidecar Host
2625
const daprPort = "50050"; // Dapr Sidecar Port of this Example Server
@@ -39,6 +38,13 @@ const server = new DaprServer(serverHost, serverPort, daprHost, daprPort, Commun
3938
const client = new DaprClient(daprHost, daprPort, CommunicationProtocolEnum.GRPC);
4039
```
4140

41+
##### Client Library
42+
A library that provides methods for how an application communicates with the Dapr sidecar.
43+
44+
##### Server Library
45+
A library for how an application registers bindings / routes with Dapr. The `startServer` method is used to start the server and bind the routes.
46+
47+
4248
## Building blocks
4349

4450
The JavaScript SDK allows you to interface with all of the [Dapr building blocks]({{< ref building-blocks >}}).
@@ -61,7 +67,7 @@ async function start() {
6167
return { hello: "world received from POST" };
6268
}, { method: HttpMethod.POST });
6369

64-
//GET listener
70+
// GET listener
6571
await server.invoker.listen("hello-world", async () => {
6672
return { hello: "world received from GET" };
6773
}, { method: HttpMethod.GET });
@@ -74,16 +80,16 @@ async function start() {
7480
const serviceAppId = "my-dapr-app-id";
7581
const serviceMethod = "say-hello";
7682

77-
//POST Request
83+
// POST Request
7884
const response = await client.invoker.invoke(serviceAppId , serviceMethod , HttpMethod.POST, { hello: "world" });
7985

80-
//GET Request
86+
// GET Request
8187
const response = await client.invoker.invoke(serviceAppId , serviceMethod , HttpMethod.GET);
8288
}
8389
```
8490
- For a full guide on service invocation visit [How-To: Invoke a service]({{< ref howto-invoke-discover-services.md >}}).
8591

86-
### Save & get application state
92+
### Save, get and delete application state
8793

8894
```javascript
8995
import { DaprClient } from "@dapr/js-sdk";
@@ -96,25 +102,25 @@ async function start() {
96102

97103
const serviceStoreName = "my-dapr-state-store";
98104

99-
//Save state
105+
// Save State
100106
const response = await client.state.save(serviceStoreName, [
101107
{
102108
key: "first-key-name",
103-
value: "Hello"
109+
value: "hello"
104110
},
105111
{
106112
key: "second-key-name",
107-
value: "World!"
113+
value: "world"
108114
}
109115
]);
110116

111-
//Get State
117+
// Get State
112118
const response = await client.state.get(serviceStoreName, "first-key-name");
113119

114-
//Get Bulk State
120+
// Get Bulk State
115121
const response = await client.state.getBulk(serviceStoreName, ["first-key-name", "second-key-name"]);
116122

117-
//Delete State
123+
// Delete State
118124
const response = await client.state.delete(serviceStoreName, "first-key-name");
119125
}
120126
```
@@ -137,7 +143,8 @@ async function start() {
137143
const topic = "topic-a";
138144
const message = { hello: "world" }
139145

140-
const response = await client.pubsub.publish(pubSubName-redis, topic, message);
146+
// Publish Message to Topic
147+
const response = await client.pubsub.publish(pubSubName, topic, message);
141148
}
142149
```
143150

@@ -155,6 +162,7 @@ async function start() {
155162
const pubSubName = "my-dapr-pubsub";
156163
const topic = "topic-a";
157164

165+
// Configure Subscriber for a Topic
158166
await server.pubsub.subscribe(pubSubName, topic, async (data: any) => console.log(`Got Data: ${JSON.stringify(data)}`));
159167

160168
await server.startServer();
@@ -228,7 +236,6 @@ async function start() {
228236
- For a full guide on secrets visit [How-To: Retrieve secrets]({{< ref howto-secrets.md >}}).
229237

230238
### Actors
231-
An actor is an isolated, independent unit of compute and state with single-threaded execution. Dapr provides an actor implementation based on the [Virtual Actor pattern](https://www.microsoft.com/en-us/research/project/orleans-virtual-actors/), which provides a single-threaded programming model and where actors are garbage collected when not in use. With Dapr's implementaiton, you write your Dapr actors according to the Actor model, and Dapr leverages the scalability and reliability that the underlying platform provides.
232239

233240
```javascript
234241
```

0 commit comments

Comments
 (0)