3 ms·
I like protobufs but I was also disappointed at the JS protobuf options. I disliked both the JS object representation and RPC transport. grpc-web in particular
by sa46 4y ago
I like protobufs but I was also disappointed at the JS protobuf options. I disliked both the JS object representation and RPC transport.
grpc-web in particular requires an Envoy proxy which seems absurdly heavyweight. I ended up using Twirp because Buf connect wasn't yet released or planned.
I rolled my own JS representation. The major differences from Connect:
- Avoid undefined if the message is not present on the wire and use an empty instance of the object instead. For recursive types, find the minimal set of fields to initialize as undefined instead of empty.
- Transparently promote some protobuf types, like google.protobuf.Timestamp to a proper Instant type (from js-joda or similar library). This makes a surprisingly large difference on reducing the number of jumps from the UI to the API.