egg框架的扩展 该扩展使得在使用egg开发微服务时能够统一
- 统一错误处理 errorHandler 中间件
- jwt jwt 中间件
ctx扩展: 3. 参数校验 ctx.validator 4. 统一错误抛出处理
app扩张 5. jwt 的相关方法
配合TS食用更佳
$ npm i egg-evo --save
// {app_root}/config/plugin.js
exports.evo = {
enable: true,
package: 'egg-evo',
};
// {app_root}/config/config.default.js
config.jwt = {
jwt: {
secret: '',
unless: { // 无需
path: [
'xxx/login',
],
},
},
}
config.middleware = [
'errorHandler', 'jwt',
];
see config/config.default.js for more detail.
可以直接在ctx或者service里面 使用如下方法
ctx.resp()
ctx.success()
ctx.throwLogic()
ctx.throwUnAuth()
ctx.validator()
Please open an issue here.