diff --git a/docs/en/guide.md b/docs/en/guide.md index f0c97e77912e..8e04701b5b88 100644 --- a/docs/en/guide.md +++ b/docs/en/guide.md @@ -307,7 +307,7 @@ Sometimes we have the need to load middleware on a specific route. In previous v Now you can provide a middleware in you application (any directory),such as `src/app/middleware/api.ts`. ```ts -import { WebMiddleware } from 'midway'; +import { Middleware, WebMiddleware, provide } from 'midway'; @provide() export class ApiMiddleware implements WebMiddleware { @@ -316,7 +316,7 @@ export class ApiMiddleware implements WebMiddleware { helloConfig; resolve() { - return async (ctx, next) => { + return async (ctx, next): Middleware => { ctx.api = '222' + this.helloConfig.b; await next(); }; diff --git a/docs/guide.md b/docs/guide.md index 8c90ab4b1c9d..07bcd5fbcc5f 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -317,7 +317,7 @@ export class HomeController { 现在可以提供一个 middleware(任意目录),比如 `src/app/middleware/api.ts`。 ```ts -import { WebMiddleware } from 'midway'; +import { Middleware, WebMiddleware, provide } from 'midway'; @provide() export class ApiMiddleware implements WebMiddleware { @@ -326,7 +326,7 @@ export class ApiMiddleware implements WebMiddleware { helloConfig; resolve() { - return async (ctx, next) => { + return async (ctx, next): Middleware => { ctx.api = '222' + this.helloConfig.b; await next(); };