API Spec Proposal
See original GitHub issueHi All!
As discussed I would love to contribute an API spec proposal for the Dapr JS SDK 😃 It’s a bit opiniated, but I hope it might lead to a discussion to see what can be improved.
Some of the key elements:
- Typescript
- Class based
- Extensibility
Usage example:
// Initialize Express
const app = express();
// Initialize dapr service
const daprService = new Dapr("YOUR_URL", "YOUR_PORT");
// State Management
const res = await daprService.state.get("my-store-name", "key");
const res = await daprService.state.save("my-store-name", [{ key: "value" }]);
// Create binding (receive / send)
const res = await daprService.binding.send("my-queue", { hello: "world" });
daprService.binding.receive(app, "my-queue", bindingInput.bind(this));
async function bindingInput(data) {
console.log("Receive Input");
console.log(data);
}
// Create Pub Sub
const res = await daprService.pubsub.publish("my-pubsub", "my-topic", { hello: "world" });
daprService.pubsub.receive(app, "my-pubsub", "my-topic", bindingInput.bind(this));
async function bindingInput(data) {
console.log("Receive Input");
console.log(data);
}
// Invoke
const res = await daprService.invoke.invoke("app-id", "method-name", { hello: "world" });
await daprService.invoke.register(app, "my-endpoint", invokedEndpoint.bind(this));
async function invokedEndpoint(data) {
console.log("Receive Input");
console.log(data);
}
Some of the code I wrote for this can be found here: https://github.com/XavierGeerinck/PublicProjects/tree/master/JS/Dapr/AutoScalingHTTP/Gateway/src/API/dapr this has not been tested yet though… so some work is left to be done.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (8 by maintainers)
Top Results From Across the Web
API documentation proposal · WebPlatform Docs
All pages have a summary description. All relevant information from the spec is included in the documentation. A link to the specification is...
Read more >API Specifications Conference (ASC) 2022 – Call for Proposals
API Specifications Conference (ASC) 2022 – Call for Proposals ... After a fantastic inaugural event in 2019, successful virtual events in 2020 and ......
Read more >What is an API: Definition, Types, Specifications, Documentation
API components. Application programming interfaces consist of two components: technical specification, describing the data exchange options ...
Read more >Engine API spec improvement proposal · Issue #321 - GitHub
Main ideas behind this proposal were brought up during the Engine API session at the Devcon R&D workshop. Thanks everyone attended for ...
Read more >[Draft Idea/Spec/Proposal/Api] Idea for better accessibility in ...
Hi all! How are you guys? Problem I would like web pages to have automatic zoom… for example suppose I click on any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have been working on this in a separate repo: https://github.com/Roadwork/dapr-js-sdk I am now waiting for the original maintainers to discuss what to do 😃
Let’s hear from other maintainers before agreeing on that.