npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@exocet/pandora-protobuf

v0.0.1-alpha.1

Published

Pandora's protobuf message parser

Downloads

1

Readme

Pandora Protobuf

Addon to provide flow and setup functions to encode/decode Protobuf 3 using protobufjs.

npm install --save @exocet/pandora-protobuf

Concepts

Message envelope

The message envelope creates a pattern for transposing data between endpoints, this pattern is defined in the file "lib / standard.proto":

syntax = "proto3";

package pandora.standard;

message MessageEnvelope {
	bytes data = 1;
	repeated bytes collection = 2;
	uint32 total = 3;
}

Setup

Available features:

  • Generate protos from entity definition
  • Multiple protos defined by labels
  • Provide encoder/decoder hook
  • Flow steps: decodeProtobuf, encodeProtobuf

To add this addon into your project, put the addon spec into your endpoint YAML:

kind: Pandora/endpoint
metadata:
  name: myEndpoint
spec:
  addons:
    - name: protobuf
      package: "@exocet/pandora-protobuf"
      flow: true
      setup: true

After the setup the following property of the context will be available:

  • .application.protos - Instance of protobufjs.Root

Hooks

The hooks created by this addon are:

  • protobufEncoder (.service.hooks.useHook('protobufEncoder')) - Synchronous hook to encode data to protobuf
    const [protobufEncoder] = service.hooks.useHook('protobufEncoder');
    const encoded = protobufEncoder('myNamespace.myEntity.myLabel', data);
  • protobufDecoder (.service.hooks.useHook('protobufDecoder')) - Synchronous hook to decode protobuf
    const [protobufDecoder] = service.hooks.useHook('protobufDecoder');
    const data = protobufDecoder('myNamespace.myEntity.myLabel', encoded);

Flow

The provided flow type and steps are listed bellow:

  • decodeProtobuf - This flow decodes protobuf:
    kind: Pandora/flowStep
    metadata:
      name: decodeProtobuf
    spec:
      type: decodeProtobuf
      options:
        inboundFrom: request # JSON Path to acquire protobuf from execution context
    	outboundTo: request # JSON path to put the decoded data
    	wrappedMessageEnvelope: true # Decode inbound wrapped in message envelope
    	collectionAsPayload: true # If the message envelope contains a collection then this flow will put the collection as outbound
    	encodingFrom: null # JSON Path to execution value that contains the current encoding of inbound, if it's specified then this flow will only decode the inbound if the value is "proto3"
        entity: # The entity to parse the proto definition
          label: default
          namespace: stock
          name: product
  • encodeProtobuf - This flow encodes data to protobuf:
    kind: Pandora/flowStep
    metadata:
      name: encodeProtobuf
    spec:
      type: encodeProtobuf
      options:
        inboundFrom: response # JSON Path to acquire data from execution context
    	outboundTo: response # JSON path to put the encoded data
    	wrappedMessageEnvelope: true # Wraps the outbound in message envelope
    	encodingFrom: null  # JSON Path to execution value that contains the desired encoding of outbound, if it's specified then this flow will only encode the inbound if the value is "proto3"
        entity: # The entity to parse the proto definition
          label: default
          namespace: stock
          name: product