egg-decorator
v1.1.2
Published
Egg decorator
Downloads
2
Maintainers
Readme
egg-decorator
Install
$ npm i egg-decorator --save
Usage
// {app_root}/config/plugin.js
exports.decorator = {
enable: true,
package: 'egg-decorator',
};
Configuration
// {app_root}/config/config.default.js
exports.decorator = {
};
see config/config.default.js for more detail.
Example
import { Controller } from 'egg'
import { pretty } from 'egg-decorator'
@pretty()
class TestController extends Controller {
index() {
return true
}
post() {
return new Error('error-message')
}
}
export default TestController
/*
* index output: { success: true, data: true, errorCode: null, errorMsg: null }
* post output: { success: false, data: null, errorCode: -1, errorMsg: "error-message" }
*/
Questions & Suggestions
Please open an issue here.