@v-tools/v-rpc
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @v-tools/v-rpc

Weekly Downloads

1

Version

0.1.7

License

MIT

Unpacked Size

57.9 kB

Total Files

45

Last publish

Collaborators

  • fuji_haruka
  • realglobe