Overview
This package contains Protocol Buffer definitions and generated TypeScript code for RPC services using SAF.
Prerequisites
You need the Protocol Buffers compiler (protoc) installed to generate TypeScript code from the proto definitions:
- macOS:
brew install protobuf
- Linux:
apt-get install protobuf-compiler
- Windows: Download from protobuf releases
Usage
It's a bit janky. Right now to get this to work, you basically should copy @saflib/identity-rpcs and adjust.
A full package includes:
generate.sh
- a custom script for generating the TypeScript code from the proto files.protos/
- the proto files, one for each service.env.schema.json
- include the env variable for the grpc port.env.ts
- generated from the schema withnpm exec saf-env generate
.index.ts
- exports the generated code and types, and returns a client that is mocked ifNODE_ENV
is"test"
.package.json
- includesgenerate
script which cleans thedist
folder and runsgenerate.sh
.
Defining RPCs and Services
Each request should include SafAuth
and SafRequest
.
Each response should return oneOf
either a successful response or an error.