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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hemera-avro

v3.0.1

Published

This is a plugin to use Avro with Hemera

Readme

Hemera-avro package

npm styled with prettier

This is a plugin to use Avro with Hemera.

Apache Avro™ is a data serialization system.

Features

  • No schema for you pattern is required
  • The request and response schema of a server method (add) is validated by Avro™
  • Flexible base schema
  • Easy to start

Example without payload schema

Only the protocol schema will be validated with Avro

const Hemera = require('nats-hemera')
// Use NATS driver >= 0.7.2
const nats = require('nats').connect({ 
  preserveBuffers: true
})
const HemeraAvro = require('hemera-avro')

const hemera = new Hemera(nats, {
  logLevel: 'info'
})

hemera.use(HemeraAvro)

Example with payload schema

hemera.ready(() => {

  let Avro = hemera.avro

  const type = Avro.parse({
  name: 'Person',
  type: 'record',
  fields: [{
      name: 'a',
      type: 'int'
    }]
  })

  hemera.add({
    topic: 'peopleDirectory',
    cmd: 'create',
    avro$: type // We know how to encode the request
  }, (req, cb) => {

    cb(null, { a: 1 })
  })

  hemera.act({
    topic: 'peopleDirectory',
    cmd: 'create',
    name: 'peter',
    avro$: type // We know how to decode the response
  }, function (err, resp) {

    this.log.info('Result', resp)
  })
})

Use Type inference to auto-generate your schema

const type = avro.Type.forValue([1, 4.5, 8])
// We can now encode or any array of floats using this type:
const buf = type.toBuffer([4, 6.1])
const val = type.fromBuffer(buf) // [4, 6.1]
// We can also access the auto-generated schema:
const schema = type.schema()
const JSON = JSON.stringify(schema) // Copy & Paste

Base Schema

The pattern is encoded to JSON byte-array when it's from type object or array. Primitive values (boolean, strings, numbers) are encoded with Avro. The error, delegate, meta and request data are predefined with a fixed schema. Here a list of the specification.

  • delegate: Can be a Map of strings, boolean, number
  • meta: Can be a Map of strings, boolean, number
  • result: You can use your own schema. If you don't define it the message is interpreted as binary (JSON encoded schema-less)
  • error:
    • name: Name of the error
    • message: Message of the error
    • stack: Stack of the error
    • code: Code of the error
    • statusCode: Code of the error when using hemera-web
    • details: Can be a Map of strings, boolean, number to add additional data
    • hops: An array of services which were involved in this request