question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API Spec Proposal

See original GitHub issue

Hi 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
XavierGeerinckcommented, May 31, 2021

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 😃

1reaction
artursouzacommented, Jun 15, 2021

Let’s hear from other maintainers before agreeing on that.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found