This is part of scalecube-js project, see more at https://github.com/scalecube/scalecube-js
Full documentation
This package provides gateway implementation for NodeJS based on rsocket websocket
interface Gateway {
constructor(options: {port: number, requestResponse?: RequestHandler, requestStream?: RequestHandler});
start: (options: { serviceCall: ServiceCall }) => void;
stop: () => void;
}
import { createMicroservice } from '@scalecube/scalecube-microservice';
import { Gateway } from '@scalecube/rsocket-ws-gateway';
const definition = {
serviceName: 'serviceA',
methods: {
methodA: { asyncModel: ASYNC_MODEL_TYPES.REQUEST_RESPONSE },
},
};
const reference = { methodA: () => Promise.resolve('ok') };
const services = [{ definition, reference }];
const ms = createMicroservice({ services });
const serviceCall = ms.createServiceCall({});
const gateway = new Gateway({ port: 3000 });
gateway.start({ serviceCall });
import { createGatewayProxy } from '@scalecube/rsocket-ws-gateway/dist/createGatewayProxy';
const definition = {
serviceName: 'serviceA',
methods: {
methodA: { asyncModel: ASYNC_MODEL_TYPES.REQUEST_RESPONSE },
},
};
const proxy = await createGatewayProxy('ws://localhost:3000', definition);
const resp = await proxy.methodA() // => 'ok'