egg-router-rs-decorator
装饰者模式写egg-router(Routers for eggjs by decorator pattern)。
Usage
For Install
npm install --save egg-router-rs-decorator
Setup
In router.ts
or route.js
// router.ts or route.js;;
Prefix Url Globally
// router.ts or `router.js` // controller.ts or `controller.js` @routerDecorator //===>>/api/user async { thisctxbody = 'hello, egg-router-decorator.' }
Prefix Url For Controller
// controller.ts or `controller.js`; @routerDecoratorprefix'/home' @routerDecorator //===>>/home/test async { thisctxbody = 'hello, egg-router-decorator.' }
Router Middleware
Router middleware will run before the target function.
Example
;; // @router.prefix('/example') // isLogin middleware // hasDelAuth middleware