0.3.0 • Published 9 years ago

@koax/route v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 years ago

route

Build status Git tag NPM version Code style

Simple route middlekoax for koax.

Installation

$ npm install @koax/route

Usage

import koax from 'koax'
import {route, request} from '@koax/route'

let router = koax()

router.use(route('/dep', () => 'norf'))
router.use(route('/foo', function * () {
  let res = yield request('/dep')
  return 'bar ' + res
}))

router(request('/foo')).then((res) => res) // => 'bar norf'

API

route(path, handler)

Route middleware.

  • path - path
  • handler - function to execute on matched path. handler has signature handler(params).

Returns: koax middleware

request(path, params)

Request action creator.

  • path - path to request
  • params - params to path to handler

Returns: action object

mount(path, middleware)

Mount middleware.

  • path - path to mount middleware at
  • middleware - middleware to mount

Returns: koax middleware

License

MIT