0.1.7 • Published 4 years ago

@v-tools/v-rpc v0.1.7

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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

0.1.7

4 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago