Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

rpcx

0.0.0 • Public • Published

Create RPC gateway:

import { Gateway } from 'rpcx';
 
const gateway = new Gateway({
  mongo: { ... },
});
gateway.set('getUsers', async (ctx, req, res) { ... });
gateway.set('getUserById', async (ctx, req, res) { ... });
gateway.set('createUser', async (ctx, req, res) { ... });
gateway.set('createUser', null); // remove
gateway.catch('createUser', async (err, ctx, req, res) { ... });
await gateway.perform('createUser', { ... });

Expose RPC gateway through HTTP:

import { HttpServer } from 'rpcx';
 
const server = new HttpServer(gateway, {
  host: 'localhost',
  port: 4444,
});
await server.listen();
await server.close();

Expose RPC gateway through WebSocket:

import { WsServer } from 'rpcx';
 
const server = new WsServer(gateway, {
  host: 'localhost',
  port: 4444,
});
await server.listen();
await server.close();

Install

npm i rpcx

DownloadsWeekly Downloads

2

Version

0.0.0

License

MIT

Unpacked Size

8.13 kB

Total Files

7

Last publish

Collaborators

  • avatar