alepha@docs:~/docs/packages$
cat [email protected] | pretty1 min read
Last commit:
#@alepha/protobuf - @alepha/protobuf
#Installation
npm install @alepha/protobuf
#Overview
Protocol Buffers support.
Registers a protobuf codec, so any Alepha schema can be encoded to the
binary wire format — or to base64, for text transports:
ts
1const schema = z.object({ name: z.text(), age: z.integer() });2const bytes = alepha.codec.encode(schema, value, {3 as: "binary",4 encoder: "protobuf",5});6const back = alepha.codec.decode(schema, bytes, { encoder: "protobuf" });
Features:
- Message serialization/deserialization
- Schemas are lowered through JSON Schema, so no zod internals are touched
- proto3 defaults are restored on decode, including enum zero values
#API Reference
#Providers
ProtobufProvider— Converts Alepha schemas to Protobuf definitions, and encodes/decodes againstProtobufSchemaCodec— ProtobufSchemaCodec handles encoding/decoding for Protobuf format.