nats-rpc-poc
v0.0.2
Published
This library allows you to wrap your classes and use them over the network
Downloads
18
Readme
NATS JSON-RPC PoC
This library allows you to wrap your classes and use them over the network
Usage
- Wrap your class
const nastTransportProvider = await NatsTransportProvider.create()
await nastTransportProvider.exposeService('MyService', new MyServiceClass())- Write client code
const nastTransportProvider = await NatsTransportProvider.create()
const myService = await nastTransportProvider.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
$ yarnExample
Run in two different terminals
$ yarn start:service$ yarn start:client