kb-actions
v0.1.1
Published
Action helper for koa and koa-boot
Downloads
2
Readme
#kb-actions
This module provides an easy way to use firewalls with koa actions.
- wraps actions and their respective firewalls in order to always get through all generators, no matter how and where the actions is called.
- links each action to a name in order to make them more accessible.
##Installation
$ npm install kb-actions --save
##API
###KbActions
action( generator
action [, array|generator
firewalls] )
Returns an action instance.
####get( string
name )
Returns an action middleware by its name.
####getAction( string
name )
Returns an action by its name.
####set( string
name, Action|generator
action [, array|generator
firewalls] )
Attaches an action to a name.
####set( object
actions )
Attaches actions by object property name. Each action could be an instance of Action or an object with action and firewalls properties.
kb.set({
action1: {
action: function * () {},
firewalls: [function * () {}]
},
action2: myAction // instance of kb.action
});
####getAction( string
name )
Returns an action by its name.
###Action
####addFirewall( generator
)
Adds a firewall to the action after the previous ones.
####middleware Returns the action middleware generator.