plugiator
2018-10-11
admin
plugiator是什么
什么是plugiator,hapi plugins creator
plugiator使用教程帮助文档
plugiator
A hapi plugins creator
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
本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。
转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]
本文地址:https://www.javascriptcn.com/read-42392.html
文章标题:plugiator