Skip to content

turing-babycare/egg-evo

Repository files navigation

egg-evo

egg框架的扩展 该扩展使得在使用egg开发微服务时能够统一

middleware扩展:

  1. 统一错误处理 errorHandler 中间件
  2. jwt jwt 中间件

ctx扩展: 3. 参数校验 ctx.validator 4. 统一错误抛出处理

app扩张 5. jwt 的相关方法

配合TS食用更佳

Install

$ npm i egg-evo --save

Usage

// {app_root}/config/plugin.js
exports.evo = {
  enable: true,
  package: 'egg-evo',
};

Configuration

// {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.

Example

可以直接在ctx或者service里面 使用如下方法

ctx.resp()
ctx.success()
ctx.throwLogic()
ctx.throwUnAuth()
ctx.validator()

Questions & Suggestions

Please open an issue here.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published