Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zkochan/plugiator
A hapi plugins creator
https://github.com/zkochan/plugiator
Last synced: 10 days ago
JSON representation
A hapi plugins creator
- Host: GitHub
- URL: https://github.com/zkochan/plugiator
- Owner: zkochan
- License: mit
- Created: 2016-01-10T19:24:07.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-25T19:53:04.000Z (about 8 years ago)
- Last Synced: 2024-11-25T08:40:42.322Z (28 days ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# plugiator
A hapi plugins creator
[![Dependency Status](https://david-dm.org/zkochan/plugiator/status.svg?style=flat)](https://david-dm.org/zkochan/plugiator)
[![Build Status](https://travis-ci.org/zkochan/plugiator.svg?branch=master)](https://travis-ci.org/zkochan/plugiator)
[![npm version](https://badge.fury.io/js/plugiator.svg)](http://badge.fury.io/js/plugiator)## How to install it?
``` sh
npm install --save plugiator
```# Usage
## `plugiator.create(attributes, register)`
Creates a plugin with the passed in attributes and register function.
```js
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.```js
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.
```js
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](https://www.kochan.io)