plugiator

0.2.1 • Public • Published

plugiator

A hapi plugins creator

Dependency Status Build Status npm version

How to install it?

npm install --save plugiator

Usage

plugiator.create(attributes, register)

Creates a plugin with the passed in attributes and register function.

const plugiator = require('plugiator')
 
function register(server, opts, next) {
  server.decorate('server', 'foo', 'bar')
  next()
}
 
module.exports = plugiator.create({
  name: 'foo',
  version: '1.0.0',
}, register)
 
// or set just the name
module.exports = plugiator.create('foo', register)

plugiator.anonymous(register)

Creates a plugin with the passed in register function and random attributes. Might be useful for unit tests.

function register(server, opts, next) {
  server.decorate('server', 'foo', 'bar')
  next()
}
 
module.exports = plugiator.anonymous(register)

plugiator.noop([attributes])

Creates a plugin that does nothing.

module.exports = plugiator.noop()
 
// can have attributes specified
module.exports = plugiator.noop('noop-plugin')
 
//or
module.exports = plugiator.noop({
  name: 'noop-plugin'
})

License

MIT © Zoltan Kochan

Readme

Keywords

Package Sidebar

Install

npm i plugiator

Weekly Downloads

3

Version

0.2.1

License

MIT

Last publish

Collaborators

  • zkochan