0.5.6 • Published 6 years ago

@superhero/router v0.5.6

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Router

Licence: MIT


npm version

A router that offers an hierarchy of dispatchers to an event bus.

Install

npm install @superhero/router

...or just set the dependency in your package.json file:

{
  "dependencies":
  {
    "@superhero/router": "*"
  }
}

Example

const
EventBus  = require('events');
bus       = new EventBus(),
debugging = true,
routes    =
[
  {
    name        :  'authentication',
    dispatchers : ['api/authentication']
  },
  {
    name        :  'authorization',
    dispatchers : ['api/authorization']
  },
  {
    name        :  'unauthorize',
    dispatchers : ['api/unauthorize']
  },
  {
    dispatchers : ['api/authorize'],
    children    :
    [
      {
        name        :  'foo',
        dispatchers : ['api/foo']
      },
      {
        name        :  'bar',
        acl         : ['admin','editor'], // optional acl validation, will
                                          // validate to first object sent as
                                          // parameter through the member
                                          // variable "role"
        dispatchers : ['api/bar']
      }
    ]
  }
];

require('@superhero/router')(bus, routes, debugging);

A dispatcher can break the dispatcher loop by throwing an object with the attributes name and context, which will be triggered as an event, or throw "nothing" (eg: false, 0, undefined...).

0.5.6

6 years ago

0.5.5

6 years ago

0.5.4

6 years ago

0.5.3

6 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago