Skip to content

Commit

Permalink
docs(middleware): add description of import koa middleware (eggjs#1805)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored and popomore committed Dec 11, 2017
1 parent c152dee commit 4c9eacb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/source/en/basics/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,25 @@ module.exports = {
};
```

If the third-party Koa middleware do not follow the rule, then you can wrap it youself:

```js
// config/config.default.js
module.exports = {
webpack: {
compiler: {},
others: {},
},
};

// app/middleware/webpack.js
const webpackMiddleware = require('some-koa-middleware');

module.exports = (options, app) => {
return webpackMiddleware(options.compiler, options.others);
}
```

## General Configuration

These general config fields are supported by middleware loaded by the application layer or built in by the framework:
Expand Down
19 changes: 19 additions & 0 deletions docs/source/zh-cn/basics/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,25 @@ module.exports = {
};
```

如果使用到的 Koa 中间件不符合入参规范,则可以自行处理下:

```js
// config/config.default.js
module.exports = {
webpack: {
compiler: {},
others: {},
},
};

// app/middleware/webpack.js
const webpackMiddleware = require('some-koa-middleware');

module.exports = (options, app) => {
return webpackMiddleware(options.compiler, options.others);
}
```

## 通用配置

无论是应用层加载的中间件还是框架自带中间件,都支持几个通用的配置项:
Expand Down

0 comments on commit 4c9eacb

Please sign in to comment.