koa-ctrl
[![License][license-image]][license-url]
koa-ctrl is used to define controller base koa@v2.
Install
$ npm i koa-ctrl --save
API
Controllerprototypeactionname action
Example
example-1
const controller = controlleraction'doHello' async { ctxbody = 'hello' await } // response.body -> 'hello'
example-2
const controller = controlleraction'doHello' before: async { ctxbody = 'before' await } action: async { ctxbody += '->action' await } after: async { ctxbody += '->after' await } // response.body -> 'before->action->after
example-3
const controller = controlleraction'doHello' before: async { ctxbody = 'before' await } action: async { ctxbody += '->action' await } // response.body -> 'before->action
Test
$ npm test
License
MIT