kb-actions
Action helper for koa and koa-boot
Last updated 6 years ago by cahnory .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install kb-actions 
SYNC missed versions from official npm registry.

#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.

Current Tags

  • 0.1.1                                ...           latest (6 years ago)

2 Versions

  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |