The Grapevine API is defined with Protobuf. Download the compiler here.
Use the latest proto3
syntax.
TypeScript stubs are copied to the app/api
directory. They can be imported with the @api
alias.
import { Messages, Message } from '@api/message';
The imports double as interfaces and factory methods. Full usage.
// api/message.ts
interface Message {
content: string
}
const Message = {
encode(person): Writer { ... }
decode(reader): Message { ... }
toJSON(person): unknown { ... }
fromJSON(data): Message { ... }
}
The Protobufs must be recompiled after any changes are made to the *.proto
files so the consumers have the latest version.
./compile.sh