night-route

0.1.0 • Public • Published

night-route

NPM Version Build Status Node.js Version

fast routing without regexp

using with koa

const { Router } = require('night-route/koa')
 
let router = new Router()
router.get('/size/:width/:height', ctx => {
    ctx.body = ctx.params.width * ctx.params.height
})
 
app.use(router.routes())

in batch

router.route('/posts', {
  get (ctx) {}
  post (ctx) {}
})
 
router.route('/posts/:id', middleware, middleware2, {
  get (ctx) {},
  put (ctx) {},
  delete (ctx) {}
})

shorthands

const { GET } = require('night-route/koa')
 
app.use(GET('/', ctx => {
  ctx.body = "index"
}))

more http methods

router.route('TRACE', ctx => {})

Readme

Keywords

Package Sidebar

Install

npm i night-route

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • zf