Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including pomegranate with all npm packages installed. Try it out:

var pomegranate = require("pomegranate")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pomegranate v6.0.0

Super flexible whitebox web application framework

Pomegranate 4 Beta

A wildly flexible application framework.

NPM Version Linux

What does it do?

Simply? Pomegranate is a framework to build other frameworks, though it just as happily handles general application programming tasks.

Pomegranate is a graybox, Inversion of Control based application framework. It ingests simple plugins, sorts them topologically and runs the hooks they expose. It supports polymorphic dependencies and simple, expressive configuration external to its plugins.

So, how's it going to make my life easier?

A modern web backend, REST Api, or microservice doesn't live in it's own tidy little box just waiting for connections. The need to talk to, and interface with SQL Databases, Redis, S3 buckets and mail services among others, presents one of the greatest challenges in an asynchronous programming enviornment. Pomegranate steps in and provides plugins a simple hook interface for managing the entire lifecycle of your code, without events or callback/promise hell.

Write the code you are already writing today.

Pomegranate plugins are simple structures that make it easy to separate concerns and write unit tests. You can export one plugin from a module, and provide a very specific functionality, or you can export an array of them and build and entire application or framework. Simple plugins are the building blocks to complex applications.


The commands below will install Pomegranate and the example plugin stack, as well as create the necessary configuration files and plugin work directories.

$ npm init
$ npm install --save pomegranate pomegranate-example-plugin
$ node_modules/.bin/pomegranate init .


You can exclude the node_modules/.bin part if you have it on your $PATH, or have Pomegranate installed globally.

$ node_modules/.bin/pomegranate start


Writing Plugins is easy and intuitive. If we wanted to wrap the Node http server in a plugin we could do something like this. In just 26 lines of code we can abstract the entire lifecycle of creating, starting and stopping an http server, with the added benefit of user overridable default configs. If you need access to other plugins, simply pass a function with parameter names matching the dependencies you need and they will be available to you inside.

module.exports = {
  options: {host: 'localhost', port: 8080},
  metadata: {name: 'HTTP', type: 'action'},
  plugin: {
    load: function(inject, loaded){

      // Router here assumes another plugin that provides your routing stack.
        this.server = require('http').createServer(Router)
        loaded(null, null)
      }, this)

      * This will work just as well.
      * var Router = inject('Router')
      * this.server = require('http').createServer(Router)
      * loaded(null, null)

    start: function(done){
      this.server.listen(this.options.port,, function(err){
        if(err) return done(err)
        return done()
    stop: function(done){
        if(err) return done(err)
        return done()

Pomegranate plugins each expose a singular configuration object that both act as default settings, as well as user configurable options. As you are adding or writing plugins, it is helpful to have a way to generate these so you don't forget anything. Lucky for us there is simple command to do just that.

$ pomegranate build

You can checkout detailed documentation about Pomegranate, Plugins, and the underlying modules that support it here:

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free