@midwayjs/express 3.4.6 → 3.4.10

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.
@@ -4,6 +4,7 @@ export declare const express: {
4
4
  contextLoggerFormat: (info: any) => string;
5
5
  };
6
6
  export declare const cookieParser: {
7
+ enable?: boolean;
7
8
  secret?: string | string[];
8
9
  options?: CookieOptions;
9
10
  };
@@ -23,7 +23,9 @@ exports.express = {
23
23
  return `${info.timestamp} ${info.LEVEL} ${info.pid} [${label}] ${info.message}`;
24
24
  },
25
25
  };
26
- exports.cookieParser = {};
26
+ exports.cookieParser = {
27
+ enable: true,
28
+ };
27
29
  exports.bodyParser = {
28
30
  enable: true,
29
31
  json: {
@@ -27,10 +27,12 @@ let ExpressConfiguration = class ExpressConfiguration {
27
27
  var _a, _b;
28
28
  const keys = (_a = this.configService.getConfiguration('express.keys')) !== null && _a !== void 0 ? _a : this.configService.getConfiguration('keys');
29
29
  const cookieParserConfig = this.configService.getConfiguration('cookieParser');
30
- // add cookie parser middleware
31
- this.expressFramework
32
- .getMiddleware()
33
- .insertFirst(cookieParser((_b = cookieParserConfig.secret) !== null && _b !== void 0 ? _b : keys, cookieParserConfig.options));
30
+ if (cookieParserConfig.enable) {
31
+ // add cookie parser middleware
32
+ this.expressFramework
33
+ .getMiddleware()
34
+ .insertFirst(cookieParser((_b = cookieParserConfig.secret) !== null && _b !== void 0 ? _b : keys, cookieParserConfig.options));
35
+ }
34
36
  // add body parser
35
37
  const bodyparserConfig = this.configService.getConfiguration('bodyParser');
36
38
  if (bodyparserConfig.enable) {
@@ -44,6 +44,10 @@ let MidwayExpressMiddlewareService = class MidwayExpressMiddlewareService {
44
44
  const classMiddleware = await this.applicationContext.getAsync(fn);
45
45
  if (classMiddleware) {
46
46
  fn = await classMiddleware.resolve(app);
47
+ if (!fn) {
48
+ // for middleware enabled
49
+ continue;
50
+ }
47
51
  // wrap async middleware
48
52
  fn = wrapAsyncHandler(fn);
49
53
  if (!classMiddleware.match && !classMiddleware.ignore) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/express",
3
- "version": "3.4.6",
3
+ "version": "3.4.10",
4
4
  "description": "Midway Web Framework for Express",
5
5
  "main": "dist/index",
6
6
  "typings": "index.d.ts",
@@ -26,14 +26,14 @@
26
26
  "devDependencies": {
27
27
  "@midwayjs/decorator": "^3.4.4",
28
28
  "@midwayjs/logger": "^2.15.0",
29
- "@midwayjs/mock": "^3.4.6",
29
+ "@midwayjs/mock": "^3.4.10",
30
30
  "@types/body-parser": "1.19.2",
31
31
  "@types/express": "4.17.13",
32
32
  "fs-extra": "10.0.1"
33
33
  },
34
34
  "dependencies": {
35
- "@midwayjs/core": "^3.4.6",
36
- "@midwayjs/express-session": "^3.4.6",
35
+ "@midwayjs/core": "^3.4.10",
36
+ "@midwayjs/express-session": "^3.4.10",
37
37
  "body-parser": "1.20.0",
38
38
  "cookie-parser": "^1.4.6",
39
39
  "express": "4.18.1"
@@ -46,5 +46,5 @@
46
46
  "engines": {
47
47
  "node": ">=12"
48
48
  },
49
- "gitHead": "36687482782bcf526efc2a4773c09e166820c1a8"
49
+ "gitHead": "aeb117633ecbc3299002b220f436dc3b5450d361"
50
50
  }