Skip to content
Makes your local function public RPC method
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
doc
example
lib
test
.gitignore
.npmignore
.prettierrc.yml
.travis.yml
LICENSE
README.md
package-lock.json
package.json
tsconfig.json
tslint.json
typedoc.json

README.md

v-rpc

RPC forwarding server. v-rpc makes your local function public RPC method.

1 minute example

Install v-rpc.

$ npm install @v-tools/v-rpc

Server code.

const { ForwardServer } = require('@v-tools/v-rpc')

const server = new ForwardServer()

void server.listen(5000).then(() => {
  console.log(`Server listening on port ${5000}`)
})

Service client code.

const { ServiceClient } = require('@v-tools/v-rpc')

const publicMethod = (name: string) => 'Hello ' + name + '\n'

const service = new ServiceClient({
  method: publicMethod,
  serviceId: 'hello_service',
  url: `http://localhost:5000`,
})

void service.connect().then(() => {
  console.log(`Service connected to the server`)
})

Call service method by curl.

$ curl -X POST -H "Content-Type: text/plain" -d "John" http://localhost:5000/services/hello_service
Hello John

API Documentation

API Documentation

You can’t perform that action at this time.