Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
timonson committed Oct 2, 2021
1 parent 8ec5ebe commit 0155db2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ JSON-RPC 2.0 library (server and client) with HTTP and WebSockets support for

### respond

Takes `Methods`, `ServerRequest` and `Options`.
Takes `Methods`, `ServerRequest` and `Options`. Look
[here](https://github.com/timonson/gentle_rpc/blob/master/server/response.ts)
for more information about `Options`.

```typescript
import { listenAndServe } from "https://deno.land/[email protected]/http/server.ts";
Expand Down Expand Up @@ -141,13 +143,10 @@ let noise2 = await remote.batch({

### WebSockets

The support for WebSockets is still experimental and has not been fully tested
yet.

#### call

Takes a string and an `Array<JsonValue>` or `Record<string, JsonValue>` object
and returns `Promise<JsonValue | undefined>`.
and returns `Promise<JsonValue>`.

```typescript
const noise = await remote.call("callNamedParameters", {
Expand All @@ -160,6 +159,8 @@ const noise = await remote.call("callNamedParameters", {
remote.socket.close();
```

Notifications return `Promise<undefined>`.

##### notification

```typescript
Expand Down
2 changes: 1 addition & 1 deletion server/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type Options = {
publicErrorStack?: boolean;
// enable 'subscribe', 'emit' and 'unsubscribe' (only ws):
enableInternalMethods?: boolean;
// defaults to both:
// defaults to 'both':
proto?: "ws" | "http" | "both";
// Enable CORS via the "Access-Control-Allow-Origin" header (only http):
cors?: boolean;
Expand Down

0 comments on commit 0155db2

Please sign in to comment.