Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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 => {})

Keywords

install

npm i night-route

Downloadsweekly downloads

3

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar