dapr / dapr/js-sdk

Refactor service invocation API and add examples

Open
#220 1 comment 0 reactions 1 assignee Claimed by @WhitWaldo View on GitHub
enhancement triaged/resolved
Dominant language
JavaScript
Stars
217
Forks
104
PR merge metrics
No merged PRs in 30d

Description

The current service invocation API is confusing. For example, the GRPC invocation requires a HTTP verb to be passed.

From https://github.com/dapr/js-sdk/blob/master/test/e2e/main.grpc.test.ts

```js
it('should be able to listen and invoke a service with GET', async () => {
const mock = jest.fn(async (_data: object) => ({ hello: 'world' }));

await server.invoker.listen('hello-world', mock, { method: HttpMethod.GET });
const res = await client.invoker.invoke(daprAppId, 'hello-world', HttpMethod.GET);

// Delay a bit for event to arrive
// await new Promise((resolve, reject) => setTimeout(resolve, 250));

expect(mock.mock.calls.length).toBe(1);
expect(JSON.stringify(res)).toEqual(`{"hello":"world"}`);
});
```

This issue is to fix the interfaces and relevant implementations. Also update examples to show the same.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.