Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

Superset of protobuf.js to add support for some Protocol Buffer wrappers types.

Notifications You must be signed in to change notification settings

EnriqCG/protobufjs-wrapper-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecation notice (2023-07-26)

The ts-proto library recently incorporated support for Wrapper Types, as detailed in stephenh/ts-proto#762. See the original issue for further understanding of what this library tried to fix, and the comment announcing the fix.

Protobufjs with support for .google.protobuf.Timestamp

NPM

Why does this package exist?

Protobuf.js does not have support for Wrapper Types other than .google.protobuf.Any.

This (small) package adds Javascript support for google.protobuf.Timestamp through the Date class. Any Date object with Protobuf type google.protobuf.Timestamp will be serialized to Google's Wrapper Type, and be deserialized back into a Date object.

This package is a superset of Protobuf.js. It just injects a custom handler for google.protobuf.Timestamp and then calls the upstream protobufjs.loader(). Just the synchronous loader function is implemented as this is intended to be used with NestJS.

How to use the custom loader with NestJS

npm i @enriqcg/protobufjs-wrapper-types
app.connectMicroservice<MicroserviceOptions>({
  transport: Transport.GRPC,
  options: {
    url: '0.0.0.0:5000',
    package: 'package.name',
    protoPath: join(__dirname, 'path_to_proto'),
    // use this package as the custom protoloader
    protoLoader: '@enriqcg/protobufjs-wrapper-types',
  },
});

Thanks to

Pull Requests have been created on protobuf.js to address this issue, but are still open and don't look like they are going to be merged any time soon. I've based the code of this package on existing opened PRs and adapted it to make it work with Nest.JS.

About

Superset of protobuf.js to add support for some Protocol Buffer wrappers types.

Resources

Stars

Watchers

Forks