Git Product home page Git Product logo

protobufjs-wrapper-types's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.