koa-easy-route

1.0.2 • Public • Published

Koa Easy Route

NPM

Configuration-based routing for Koa.js... the Grunt of routing

Setup

Install (and mark) the dependency-

npm install --save koa-easy-route

Usage

var router = require('koa-easy-route');
app.use(router([
  {
    method: 'get',
    path: '/',
    handler: function *(next) {
      yield next
      this.body = 'text'
      yield next
    },
    middleware: [
      function *(next) {
        yield next
        this.body = 'real text'
      }
    ]
  },
  {
    method: 'post',
    path: '/',
    handler: function *(next) {
      this.body = 'post worked'
    }
  }
]))

A route must contain a method, path, and handler. You may optionally also specify middleware[], which will be compose'd.

Package Sidebar

Install

npm i koa-easy-route

Weekly Downloads

0

Version

1.0.2

License

WTFPL

Last publish

Collaborators

  • tejasmanohar