@kizzlebot/hapi-plugins
Hapi plugin to autoload other plugins.
Last updated 3 years ago by kizzlebot .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @kizzlebot/hapi-plugins 
SYNC missed versions from official npm registry.

@kizzlebot/hapi-plugins

Build Status Dependencies Dev dependencies

Plugin to autoload plugins given relative path and glob pattern. Optionally, options.plugins[pluginName] can be used to pass arguments to plugins

How to use:

  • Install hapi-plugins npm package in your project our plugin. npm i @flexshopper/hapi-plugins
  • Register plugin in your hapi server:

Registering

const server = new Hapi.Server();

server.connection();

server.register({
    register: require('hapi-plugins'),
    options: {
        relativeTo: proccess.cwd() + '/plugins',
        includes: ['path/to/**/*plugins.js'],
        ignore: ['*.git'],
        // plugin options
        plugins: {
            myPlugin: {
                host: '192.168.1.1'
            }
        }
    }
}, (err) => {
  // continue application
});

manifest style:

registrations: [
    ...
    {
        plugin: {
            register: 'hapi-plugins',
            options: {
                relativeTo: proccess.cwd() + '/plugins',
                includes: ['path/to/**/*plugins.js'],
                ignore: ['*.git'],
                // plugin options
                plugins: {
                    myPlugin: {
                        host: '192.168.1.1'
                    }
                }
            }
        }
    }
];

Options

includes

Required
Type: array

The glob pattern you would like to include

ignore

Type: array

The pattern or an array of patterns to exclude

relativeTo

Type: string

The current working directory in which to search (defaults to process.cwd())

plugins

Type: object

key-value where key is your plugin name (ie internals.register.attributes.name) and value is options to pass to plugin

Route Signature

'use strict';

const internals = module.exports = {};
internals.register = (server, options, next) => {
    // ...do stuff

    return next();
};

internals.register.attributes = {
    name: 'myplugin:',
    version: '0.0.1'
};

Current Tags

  • 0.0.1                                ...           latest (3 years ago)

1 Versions

  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 2
Dependencies (6)
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |