@midwayjs/koa 3.6.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export declare const koa: {
5
5
  contextLoggerFormat: (info: any) => string;
6
+ serverTimeout: number;
6
7
  };
7
8
  /**
8
9
  * The key that signing cookies. It can contain multiple keys seperated by `,`.
@@ -24,6 +24,7 @@ exports.koa = {
24
24
  ctx.url;
25
25
  return `${info.timestamp} ${info.LEVEL} ${info.pid} [${label}] ${info.message}`;
26
26
  },
27
+ serverTimeout: 2 * 60 * 1000,
27
28
  };
28
29
  /**
29
30
  * The key that signing cookies. It can contain multiple keys seperated by `,`.
@@ -20,7 +20,8 @@ let KoaConfiguration = class KoaConfiguration {
20
20
  init() {
21
21
  // register param decorator
22
22
  this.decoratorService.registerParameterHandler(core_1.WEB_ROUTER_PARAM_KEY, options => {
23
- return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData, options.originParamType)(options.originArgs[0], options.originArgs[1]);
23
+ var _a;
24
+ return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData, options.originParamType, (_a = options.metadata) === null || _a === void 0 ? void 0 : _a.pipes)(options.originArgs[0], options.originArgs[1]);
24
25
  });
25
26
  }
26
27
  async onReady() {
@@ -2,7 +2,7 @@
2
2
  import { BaseFramework, CommonFilterUnion, CommonMiddlewareUnion, IMidwayBootstrapOptions, MidwayFrameworkType, RouterInfo } from '@midwayjs/core';
3
3
  import { IMidwayKoaApplication, IMidwayKoaConfigurationOptions, IMidwayKoaContext } from './interface';
4
4
  import type { DefaultState, Middleware, Next } from 'koa';
5
- import { Server } from 'net';
5
+ import { Server } from 'http';
6
6
  export declare class MidwayKoaFramework extends BaseFramework<IMidwayKoaApplication, IMidwayKoaContext, IMidwayKoaConfigurationOptions, Next> {
7
7
  private server;
8
8
  private generator;
@@ -23,7 +23,7 @@ export declare class MidwayKoaFramework extends BaseFramework<IMidwayKoaApplicat
23
23
  beforeStop(): Promise<void>;
24
24
  getFrameworkType(): MidwayFrameworkType;
25
25
  getFrameworkName(): string;
26
- getServer(): Server;
26
+ getServer(): Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
27
27
  getPort(): string;
28
28
  useMiddleware(Middleware: CommonMiddlewareUnion<IMidwayKoaContext, Next, unknown>): void;
29
29
  useFilter(Filter: CommonFilterUnion<IMidwayKoaContext, Next, unknown>): void;
package/dist/framework.js CHANGED
@@ -145,6 +145,10 @@ let MidwayKoaFramework = class MidwayKoaFramework extends core_1.BaseFramework {
145
145
  }
146
146
  // register httpServer to applicationContext
147
147
  this.applicationContext.registerObject(core_1.HTTP_SERVER_KEY, this.server);
148
+ // server timeout
149
+ if (core_1.Types.isNumber(this.configurationOptions.serverTimeout)) {
150
+ this.server.setTimeout(this.configurationOptions.serverTimeout);
151
+ }
148
152
  // set port and listen server
149
153
  const customPort = (_a = process.env.MIDWAY_HTTP_PORT) !== null && _a !== void 0 ? _a : this.configurationOptions.port;
150
154
  if (customPort) {
@@ -66,6 +66,14 @@ export interface IMidwayKoaConfigurationOptions extends IConfigurationOptions {
66
66
  * Max IPs read from proxy IP header, default to 0 (means infinity)
67
67
  */
68
68
  maxIpsCount?: number;
69
+ /**
70
+ * server timeout in milliseconds, default to 2 minutes.
71
+ *
72
+ * for special request, just use `ctx.req.setTimeout(ms)`
73
+ *
74
+ * @see https://nodejs.org/api/http.html#http_server_timeout
75
+ */
76
+ serverTimeout?: number;
69
77
  }
70
78
  export declare type MiddlewareParamArray = Array<Middleware<DefaultState, IMidwayKoaContext>>;
71
79
  export interface IWebMiddleware {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/koa",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "Midway Web Framework for KOA",
5
5
  "main": "dist/index",
6
6
  "typings": "index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
27
  "@midwayjs/logger": "^2.15.0",
28
- "@midwayjs/mock": "^3.6.0",
28
+ "@midwayjs/mock": "^3.7.0",
29
29
  "@types/koa": "2.13.5",
30
30
  "@types/koa-router": "7.4.4",
31
31
  "fs-extra": "10.0.1"
@@ -33,8 +33,8 @@
33
33
  "dependencies": {
34
34
  "@koa/router": "^11.0.0",
35
35
  "@midwayjs/cookies": "^1.0.2",
36
- "@midwayjs/core": "^3.6.0",
37
- "@midwayjs/session": "^3.6.0",
36
+ "@midwayjs/core": "^3.7.0",
37
+ "@midwayjs/session": "^3.7.0",
38
38
  "koa": "2.13.4",
39
39
  "koa-bodyparser": "4.3.0"
40
40
  },
@@ -46,5 +46,5 @@
46
46
  "engines": {
47
47
  "node": ">=12"
48
48
  },
49
- "gitHead": "22643b0e8519766bb7c68b975930199fc136336e"
49
+ "gitHead": "99386083ee26b386fd508b9c892091c914e77535"
50
50
  }