@roadwork/dapr-js-sdk
Advanced tools
Comparing version 0.1.0 to 0.1.2
{ | ||
"name": "@roadwork/dapr-js-sdk", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "An unofficial Dapr (https://dapr.io) SDK for Node.js", | ||
@@ -9,3 +9,3 @@ "main": "lib/index.js", | ||
"test": "jest --runInBand", | ||
"build": "tsc", | ||
"build": "tsc --outDir build/", | ||
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"", | ||
@@ -28,6 +28,6 @@ "lint": "tslint -p tsconfig.json", | ||
"devDependencies": { | ||
"@types/express": "^4.17.9", | ||
"@types/jest": "^26.0.20", | ||
"@types/node-fetch": "^2.5.7", | ||
"jest": "^26.6.3", | ||
"@types/express": "^4.17.11", | ||
"@types/jest": "^26.0.21", | ||
"@types/node-fetch": "^2.5.8", | ||
"jest": "^26.6.4", | ||
"prettier": "^2.2.1", | ||
@@ -37,3 +37,3 @@ "ts-jest": "^26.5.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^4.1.3" | ||
"typescript": "^4.2.3" | ||
}, | ||
@@ -40,0 +40,0 @@ "repository": { |
@@ -27,3 +27,15 @@ # Dapr Node.js SDK | ||
await client.state.delete("store-name", "key"); | ||
await client.state.getBulk("store-name", [ "key1", "key2" ]); | ||
const stateOperations = [ | ||
{ | ||
operation: "upsert", | ||
request: { | ||
key: "key1", | ||
value: "myData" | ||
} | ||
} | ||
] | ||
await client.state.transaction("store-name", stateOperations) | ||
// Binding | ||
@@ -36,2 +48,56 @@ const bindingReceive = (data: any) => { console.log(data); } | ||
await client.invoker.invoke("app-id", "method", { hello: "world" }); | ||
``` | ||
const invokerListen = (req: express.Request, res: express.Response) => { console.log(data); } | ||
client.invoker.listen("method", invokerListen.bind(this), options) | ||
// Secrets | ||
await client.secret.get("secret-store-name", "key"); | ||
await client.secret.getBulk("secret-store-name", [ "key1", "key2" ]); | ||
// Actors | ||
await client.actor.invoke("GET", "actor-type", "actor-id", "method"); | ||
await client.actor.stateTransaction("actor-type", "actor-id", [{ | ||
operation: "upsert", | ||
request: { | ||
key: "key1", | ||
value: "myData" | ||
} | ||
}]) | ||
await client.actor.stateGet("actor-type", "actor-id", "key"); | ||
await client.actor.reminderCreate("actor-type", "actor-id", "name"); | ||
await client.actor.reminderGet("actor-type", "actor-id", "name"); | ||
await client.actor.reminderDelete("actor-type", "actor-id", "name"); | ||
await client.actor.timerCreate("actor-type", "actor-id", "name"); | ||
await client.actor.timerDelete("actor-type", "actor-id", "name"); | ||
``` | ||
## Reference | ||
### Service Invocation | ||
The service invocation methods are created as a warpper on the [Dapr Service Invocation API](https://docs.dapr.io/reference/api/service_invocation_api/). | ||
#### Invoking a method | ||
```javascript | ||
await client.invoker.invoke("app-id", "method", { hello: "world" }); | ||
``` | ||
#### Listening to a method call | ||
On top of the invoking, this SDK also implements a trivial way to listen to app invocations. Instead of creating your own Express server, you can simply run the following commands which will listen to calls coming in on the provided endpoint. | ||
```javascript | ||
const invokerListen = (req: express.Request, res: express.Response) => { console.log(data); } | ||
client.invoker.listen("method", invokerListen.bind(this), options) | ||
``` | ||
### State Management | ||
### Pub/Sub | ||
### Bindings | ||
### Actors | ||
### Secrets |
Sorry, the diff of this file is not supported yet
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
102
15640
3
0
2