Short-hand Protobuf Object Instantiation
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 716
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 10
Description
Is there an easy way to generate a protobuf given a native Javascript Object? What I'd like to do is this:
```
// pubsub.proto
message PublishCloudEventInput {
string clientMutationId = 1;
string id = 2;
}
message PublishCloudEventResponse {
string clientMutationId = 1;
}
service Pubsub {
rpc Publish(stream PublishCloudEventInput) returns (stream PublishCloudEventResponse);
}
```
```
// client.js
const grpc = require('grpc')
const messages = require('./build/pubsub_pb')
const services = require('./build/pubsub_grpc_pb')
var client = new services.PubsubClient('127.0.0.1:5000', grpc.credentials.createInsecure())
const publishStream = client.publish()
const p = new messages.PublishCloudEventInput({
clientMutationId: '1234',
id: '5678'
})
```
rather than
```
const p = new messages.PublishCloudEventInput()
p.setClientmutationid('1234')
p.setId('5678')
```
Contributor guide
Assessment
This issue has not been assessed yet.