protobuf-ts

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2020 License: Apache-2.0

README

protobuf-ts

Protobuf and RPC for Node.js and the Web Browser.

For the following .proto file:

syntax = "proto3";

message Person {
    string name = 1;
    uint64 id = 2;
    int32 years = 3;
    optional bytes data = 5;
}

protobuf-ts generates code that can be used like this:

let pete: Person = {
    name: "pete", 
    id: 123n, // it's a bigint
    years: 30
    // data: new Uint8Array([0xDE, 0xAD, 0xBE, 0xEF]);
};

let bytes = Person.toBinary(pete);
pete = Person.fromBinary(bytes);

pete = Person.fromJsonString('{"name":"pete", "id":"123", "years": 30}')

It can also send the data over the network to a remote server, where it can be read by other protobuf implementations.

Features

To get started, install the plugin with npm i -D @protobuf-ts/plugin and read the MANUAL to learn more.

Building this project

This is a monorepo. It uses lerna to manage versions and dependencies.

Building this project requires node, npm, protoc (3.12.3 or later), make, bazel, git.

The entire project can be built by running make. This will execute:

  • npm i - installs lerna locally
  • lerna bootstrap - installs the dependencies of all packages, linking local packages
  • lerna exec make - runs make for all packages

See Makefile for details.

The packages/ directory contains all components of protobuf-ts. Some are public npm packages, some are private and only required for development. Some components do not use JavaScript at all, for example example-dotnet-grpcweb-server.

Directories

Path Synopsis
packages
example-twirp-server/rpc/haberdasher
Package haberdasher is a generated twirp stub package.
Package haberdasher is a generated twirp stub package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL