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

pluginizer

v0.5.1

Published

A tool to create plugins or middlewares for different Javascript tools, frameworks, servers.

Readme

pluginizer

npm version Build Status Coveralls

A tool to create plugins or middlewares for different Javascript tools, frameworks, servers.

This tools helps to keep the implementation free of Hemera or Seneca keywords, which may be problematic in case of migration or running the code in multiple containers with different toolkits.

Installation

Run the install command:

npm install --save pluginizer

Usage

Consider we have a function like this (which can be wrapped in a Seneca or Hemera plugin):

const businessLogic = (msg, cb) => {
    // actual business implementation
}

module.exports = myFunction

Create Hemera plugin:

const pluginizer = require('pluginizer')

const pluginizedLogic = pluginizer.createHemeraPlugin(businessLogic, options)

// next step is loading the plugin with the Hemera instance as usual.
// hemera.use(hp(pluginizedLogic.plugin, pluginizedLogic.options)

Create Seneca plugin:

const pluginizer = require('pluginizer')

const pluginizedLogic = pluginizer.createHemeraPlugin(businessLogic, options)

// next step is loading the plugin with the Seneca instance as usual.
// seneca.use(pluginizedLogic)

Options

There are two typical way to create a module that contains function(s) which can be used in Hemera and Seneca.

Note: If you use curry or a factory it is also possible using the 'curry' option described later.

Type single function

Export a simple function like:

module.exports = (msg, cb) => { ... }
  • Set the 'pattern' to route messages to this handler.
  • Set the plugin name which will be registered internally in the toolkit.

Options will look like this:

const options = {
    pattern: {
        topic: 'someTopic',
        cmd: 'someCmd'
    },
    pluginName: 'somePluginName'
}

Your microservice will listen for the pattern and execute the wrapped business logic implementation as handler.

Type object of functions

Note: in this case the exported object property keys will be mapped as 'cmd' in the pattern automatically. In the example below add, subtract, ... will be mapped as cmd(s).

Export an object of functions like this:

module.exports = {
    add: (msg, cb) => { ... },
    subtract: (msg, cb) => { ... },
    multiply: (msg, cb) => { ... },
    divide: (msg, cb) => { ... }
}
  • Set the 'pattern' to route messages to this handler.
  • Set the plugin name which will be registered internally in the toolkit.

Options will look like this:

const options = {
    pattern: {
        topic: 'calculator'
    },
    pluginName: 'calculatorPlugin'
}

Your microservice will listen on topic 'calculator' and execute the wrapped business logic implementations as handlers respectively to the cmd<->key pairs.

Curry option

It is also common to use curry technique to call a function that will return the actual function that will be used as the handler.

module.exports = someCurryObject => (msg, cb) => {
    // actual business implementation
}

In this case the 'someCurryObject' is available in the scope of the handler. It can be useful to pass some context that can be called inside the script. Like if we want call another service, we can pass the container's communication interface as a curry object.

module.exports = ({ container }) => (msg, cb) => {
    // actual business implementation
    container.act({ topic: 'someTopic', cmd: 'someCmd', ...payload }, (err, res) => cb)
}

Example:

const options = {
    pattern: {
        topic: 'topicName',
        cmd: 'someCmd'
    },
    curry: {
        container: hemeraInstance // or senecaInstance
    }
}

So in your logic you can reference to your container instance and use the container.act(...) call to communicate to other services.

Notes

Although this library can be used alone, it is one of the artifacts of a proof-of-concept project, which is focusing to seperate the business logic implementation from the infrastructure logic to keep it as independent/adaptive/pure as possible.

If you are interested please also check the repositories listed below which can be used together to achieve the greater goal:

  • wfun - Wrap your plain JS functions into different functions, based on common patterns for plugins and middlewares.
  • npac - A lightweight Ports and Adapters Container for applications running on Node.js platform.