1.9.0 • Published 4 months ago

@push-rpc/http v1.9.0

Weekly downloads
25
License
MIT
Repository
github
Last release
4 months ago

HTTP transport for Push-RPC.

Server-side push is not supported, only client-initiated messages are enabled.

Integrates with Koa or Express for HTTP server. Uses Fetch for making HTTP requests.

How to use (with Koa)

import * as Koa from "koa"
import {createRpcServer, createRpcClient} from "@push-rpc/core"
import {createKoaHttpServer, createHttpClient} from "@push-rpc/http"

...

/* server part */
const services = {
  async getHello() {
    return "Hello from Server"
  },
}

// remote id is required for assigning separate HTTP requests to a single session 
function getRemoteId(ctx: Koa.Context) {
  return "1" // share a single session for now, real impl could use cookies or some other meaning for HTTP sessions
}

createRpcServer(services, createKoaHttpServer(5555, getRemoteId))

...

/* client part */
const {remote} = await createRpcClient(0, () => createHttpClient("http://localhost:5555"))
console.log("From server: " + (await remote.getHello()))

Mapping between Push-RPC protocol and HTTP

All requests and responses are JSON-encoded.

Request path specifies operation to be invoked or topic to be queried. Path is static, no parameters is path are supported. Use request body instead to send parameters.

Query string parameters are not used.

When error is returned from the server, response is 400, response status string contains error message, response body contains error details in JSON-format.

1.9.0

4 months ago

1.8.3

4 months ago

1.8.2

6 months ago

1.8.1

6 months ago

1.8.0

6 months ago

1.7.1

6 months ago

1.7.0

6 months ago

1.6.5

7 months ago

1.6.3

11 months ago

1.6.2

11 months ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.8

1 year ago

1.5.7

1 year ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.6

1 year ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.4.2

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago