@plmtest/device-protobufs
v1.0.7
Published
Protobuf files for device gRPC APIs
Readme
@smartcosmos/device-protobufs
This package provides the protobuf definitions for a user 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/device-protobufs";
new GRPCServer({
configuration: {
port: config.GRPC_PORT,
host: config.GRPC_HOST,
},
logger: config.LoggerConfig,
}).addService(
{
protoPackage: "device",
protoService: "DeviceService",
protoPath: protoPaths.device, // imported from a protobuf package
},
{
serviceClass: servicePackages.device.DeviceService, // class of the service implementation
params: { remotes, models },
}
);Setting up a client
import { GRPCClient } from "@smartcosmos/cosmos-service-builder";
import protoPaths from "@smartcosmos/users-protobufs";
const grpcClients = {
...new GRPCClient({
protoPath: protoPaths.user,
logger: config.LoggerConfig,
}).connect(config.GRPC_SERVER_SAMPLE_ADDRESS),
};