0.0.2 • Published 4 years ago

@smartcosmos/sample-protobufs v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

@smartcosmos/sample-protobufs

This package provides the protobuf definitions for a sample gRPC API.

Once imported, it provides the absolute paths for proto files to set up gRPC clients and servers.

Usage

Setting up a server

import { GRPCServer } from '@smartcosmos/cosmos-service-builder';
import protoPaths from '@smartcosmos/sample-protobufs';

new GRPCServer({
  configuration: {
    port: config.GRPC_PORT,
    host: config.GRPC_HOST,
  },
  logger: config.LoggerConfig,
})
.addService({
  protoPackage: 'sample.hello',
  protoService: 'HelloService',
  protoPath: protoPaths.sample, // imported from a protobuf package
}, {
  serviceClass: servicePackages.sample.hello.HelloService, // class of the service implementation
  params: { remotes, models },
});

Setting up a client

import { GRPCClient } from '@smartcosmos/cosmos-service-builder';
import protoPaths from '@smartcosmos/sample-protobufs';

const grpcClients = {
  ...new GRPCClient({
    protoPath: protoPaths.sample,
    logger: config.LoggerConfig,
  }).connect(config.GRPC_SERVER_SAMPLE_ADDRESS),
};
0.0.2

4 years ago

0.0.1

5 years ago

0.0.1-rc.3

5 years ago

0.0.1-rc.2

5 years ago