Questions tagged [protobufjs]

protobuf.js is a pure JavaScript implementation of the Google's Protocol Buffers.

protobuf.js is a Protocol Buffers implementation on top of bytebuffer.js including a .proto parser, reflection, message class building and simple encoding and decoding in plain JavaScript. There is no compilation step required, it's super easy to use and it works out of the box on .proto files.

34 questions
7
votes
2 answers

How to encode protocol buffer string to binary using protoc

I been trying to encode strings using protoc cli utility. Noticed that output still contains plain text. What am i doing wrong? osboxes@osboxes:~/proto/bin$ cat ./teststring.proto syntax = "proto2"; message Test2 { optional string b = 2; } echo…
kpavel
  • 262
  • 3
  • 9
4
votes
1 answer

How to decode encoded protocol buffer data with a .proto file in node.js

I am new to protocol buffer and I am trying to decode data from an api response. I get encoded data from the api response and I have a .proto file to decode the data, how do I decode the data in nodeJS. I have tried using protobuf.js but I am very…
matin
  • 99
  • 1
  • 6
4
votes
1 answer

Represent a protobuf map as a json

I'm using grpcc, which is based on protobuf.js, to test my grpc service APIs. My .proto file: message MyRequest { string userId = 1; map params = 2; } I tried the following json body to send a request: {userId : "my_user_id"…
Maddy
  • 2,114
  • 7
  • 30
  • 50
3
votes
1 answer

Is there any way to decode/encode by tag but without any .proto file or json file in protobuf.js?

Is there any way to decode/encode by tag but without any .proto file or json file in protobuf.js? Or any other library? like: // read value by tag var pb = new Protobufjs.Reader(buffer); var value = pb.readInt32ByTag(1); // write value by tag var…
3
votes
1 answer

Getting `Error: 8 RESOURCE_EXHAUSTED: Received message larger than max (15217288 vs. 4194304)` in Node.js gRPC client

How to increase max message size for Node.js gRPC client? We use grpc, grpc-tools and protobufjs npm-packages: const packageDefinitions = loader.loadSync(PROTO_PATH, { includeDirs: [__dirname], longs: String, arrays: true }); const packageObject…
razon
  • 3,882
  • 2
  • 33
  • 46
3
votes
1 answer

Javascript protobuf performance

Two different modules are available for protobuf in nodejs - https://github.com/dcodeIO/ProtoBuf.js/ https://github.com/google/protobuf/tree/master/js - official but less features than the other module. Specifically, doesn't have typescript…
Nishant
  • 129
  • 1
  • 10
2
votes
1 answer

Error "pbjs: command not found" in run compile protobuf js with yarn

I update protobufjs from 6.11.2 to 7.1.2 then when I run my compiler to compile my protobufs I got this error pbjs: command not found error Command failed with exit code 127. What shall I do ?
N.SH
  • 616
  • 7
  • 20
2
votes
1 answer

how to check whether a data/payload can be decoded by protobuf or not

I have files with data (payload) in different formats (plain text, json, xlm, binary (can be decoded by protobuf)). To know how to process particular file I need to know what is the format of data in the file. The question is whether it is possible…
vich
  • 262
  • 2
  • 15
2
votes
2 answers

Error when I try to test with NestJS, Jest and GraphQLFederationModule

When I try to test with this module it gives me the following error: FAIL test/test.e2e-spec.ts (28.561s) AppController (e2e) × test (4555ms) ● AppController (e2e) › test Configuration error: Could not locate module…
dragons0458
  • 143
  • 1
  • 6
1
vote
0 answers

Error: unresolvable extensions in compiling protobuf js

My protobufjs version is 7.1.2 and my protobufjs-cli is in version 1.0.2. When I wanna compile my proto files I got this error: Error: unresolvable extensions: 'extend google.protobuf.FileOptions' in .grpc.gateway.protoc_gen_openapiv2.options,…
N.SH
  • 616
  • 7
  • 20
1
vote
0 answers

How to convert a JSON object to a Protobuf Message

Imagine I have the following JSON Object, const json = { code: 3, message: 'Test error message', details: [ { '@type': 'google.rpc.BadRequest', fieldViolations: [ { …
ololo
  • 1,326
  • 2
  • 14
  • 47
1
vote
0 answers

How to Define a Protobuf Message for Dynamic JSON data for Javascript

I using then gRPC for inter micro service communication. Both the services are written in JavaScript. In the response of the gRPC call I need to send an array for JSON objects, Which contains the nested JSON objects also and data is dynamic in the…
1
vote
0 answers

Combine every single protobuf file into one "combined.proto"

I've looked extensively for good solutions to this question. I'm fine with writing a script. I'd like to combine every single .proto file I have here into a single "combined.proto" for various reasons. The other answers I've found on here haven't…
Tregory
  • 11
  • 2
1
vote
1 answer

protobufjs load from string

I get a .proto definition as a string input, can I load it into a Root object straight from the string, for example the string might look like this let protoStr = `syntax = "proto3"; message SearchRequest { string query = 1; int32 page_number =…
Kallie
  • 147
  • 9
1
vote
0 answers

Significance of `{}` in rpc declarations

While going through the docs of protobufjs and google protobuf official guide I noticed that there is a syntax difference between rpc declarations described by both - Google protobuf guide - rpc SayHello (HelloRequest) returns…
97amarnathk
  • 957
  • 2
  • 11
  • 30
1
2 3