Skip to content

Garik-/nats-rpc-poc

Repository files navigation

NATS JSON-RPC PoC

npm version Downloads

This library allows you to wrap your classes and use them over the network

Usage

  1. Wrap your class
const natsTransportProvider = await NatsTransportProvider.create()
await natsTransportProvider.exposeService('MyService', new MyServiceClass())
  1. Write client code
const natsTransportProvider = await NatsTransportProvider.create()
const myService = await natsTransportProvider.getRemoteService<MyService>('MyService')

const result = await myService.anyMethod(param1, param2)

Don't forget to call stopService and destory for correctly close connection

Environments & dependencies

Install node modules and start NATS on nats://localhost:4222

$ docker-compose up -d
$ yarn

Example

Run in two different terminals

$ yarn start:service
$ yarn start:client

About

JSON RPC with MQ NATS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published