1.0.6 • Published 3 years ago

koa-router-transfer-class-to-router v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

transferClassToRouter

npm i koa-router-transfer-class-to-router

Methods that are prefixed with HTTP requests will be added to the route

class News {
  get(ctx){
    ctx.body = 'getIndex'
  }
  getName(ctx){
    ctx.body = 'my name is ok
  }
}
module.exports = transferClassToRouter(News)

equivalent to

const router = new require('koa-router)
router.get('/', ctx=> {
  ctx.bidy = 'getIndex
})
router.get('/name', ctx=> {
  ctx.body = 'my name is ok'
})
module.exports = router
1.0.6

3 years ago

1.0.5

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago