@midwayjs/express 3.0.4-beta.1 → 3.0.4

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.
@@ -1,5 +1,8 @@
1
1
  import { Options, OptionsJson, OptionsText, OptionsUrlencoded } from 'body-parser';
2
2
  import { CookieOptions } from 'express';
3
+ export declare const express: {
4
+ contextLoggerFormat: (info: any) => string;
5
+ };
3
6
  export declare const cookieParser: {
4
7
  secret?: string | string[];
5
8
  options?: CookieOptions;
@@ -1,6 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bodyParser = exports.cookieParser = void 0;
3
+ exports.bodyParser = exports.cookieParser = exports.express = void 0;
4
+ exports.express = {
5
+ contextLoggerFormat: info => {
6
+ var _a;
7
+ const req = info.ctx;
8
+ // format: '[$userId/$ip/$traceId/$use_ms $method $url]'
9
+ const userId = ((_a = req === null || req === void 0 ? void 0 : req['session']) === null || _a === void 0 ? void 0 : _a['userId']) || '-';
10
+ const traceId = '-';
11
+ const use = Date.now() - info.ctx.startTime;
12
+ const label = userId +
13
+ '/' +
14
+ req.ip +
15
+ '/' +
16
+ traceId +
17
+ '/' +
18
+ use +
19
+ 'ms ' +
20
+ req.method +
21
+ ' ' +
22
+ req.url;
23
+ return `${info.timestamp} ${info.LEVEL} ${info.pid} [${label}] ${info.message}`;
24
+ },
25
+ };
4
26
  exports.cookieParser = {};
5
27
  exports.bodyParser = {
6
28
  enable: true,
@@ -3,7 +3,6 @@ import { BaseFramework, IMidwayBootstrapOptions, MiddlewareRespond, MidwayFramew
3
3
  import { IMidwayExpressApplication, IMidwayExpressConfigurationOptions, Context } from './interface';
4
4
  import type { IRouter, IRouterHandler, Response, NextFunction } from 'express';
5
5
  import { Server } from 'net';
6
- import { MidwayExpressContextLogger } from './logger';
7
6
  export declare class MidwayExpressFramework extends BaseFramework<IMidwayExpressApplication, Context, IMidwayExpressConfigurationOptions, Response, NextFunction> {
8
7
  app: IMidwayExpressApplication;
9
8
  private server;
@@ -31,6 +30,5 @@ export declare class MidwayExpressFramework extends BaseFramework<IMidwayExpress
31
30
  getServer(): Server;
32
31
  getPort(): string;
33
32
  getFrameworkName(): string;
34
- getDefaultContextLoggerClass(): typeof MidwayExpressContextLogger;
35
33
  }
36
34
  //# sourceMappingURL=framework.d.ts.map
package/dist/framework.js CHANGED
@@ -10,7 +10,6 @@ exports.MidwayExpressFramework = void 0;
10
10
  const core_1 = require("@midwayjs/core");
11
11
  const decorator_1 = require("@midwayjs/decorator");
12
12
  const express = require("express");
13
- const logger_1 = require("./logger");
14
13
  const middlewareService_1 = require("./middlewareService");
15
14
  const util_1 = require("util");
16
15
  const util_2 = require("./util");
@@ -246,9 +245,6 @@ let MidwayExpressFramework = class MidwayExpressFramework extends core_1.BaseFra
246
245
  getFrameworkName() {
247
246
  return 'midway:express';
248
247
  }
249
- getDefaultContextLoggerClass() {
250
- return logger_1.MidwayExpressContextLogger;
251
- }
252
248
  };
253
249
  MidwayExpressFramework = __decorate([
254
250
  (0, decorator_1.Framework)()
package/dist/index.d.ts CHANGED
@@ -2,5 +2,4 @@ export * from './interface';
2
2
  export { MidwayExpressFramework as Framework } from './framework';
3
3
  export { ExpressConfiguration as Configuration } from './configuration';
4
4
  export * from './middlewareService';
5
- export * from './logger';
6
5
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "Framework", { enumerable: true, get: function ()
17
17
  var configuration_1 = require("./configuration");
18
18
  Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.ExpressConfiguration; } });
19
19
  __exportStar(require("./middlewareService"), exports);
20
- __exportStar(require("./logger"), exports);
21
20
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/express",
3
- "version": "3.0.4-beta.1",
3
+ "version": "3.0.4",
4
4
  "description": "Midway Web Framework for Express",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -23,16 +23,16 @@
23
23
  ],
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@midwayjs/decorator": "^3.0.4-beta.1",
27
- "@midwayjs/logger": "^2.14.0",
28
- "@midwayjs/mock": "^3.0.4-beta.1",
26
+ "@midwayjs/decorator": "^3.0.4",
27
+ "@midwayjs/logger": "^2.15.0",
28
+ "@midwayjs/mock": "^3.0.4",
29
29
  "@types/body-parser": "1.19.2",
30
30
  "@types/express": "4.17.13",
31
31
  "fs-extra": "10.0.0"
32
32
  },
33
33
  "dependencies": {
34
- "@midwayjs/core": "^3.0.4-beta.1",
35
- "@midwayjs/express-session": "^3.0.4-beta.1",
34
+ "@midwayjs/core": "^3.0.4",
35
+ "@midwayjs/express-session": "^3.0.4",
36
36
  "body-parser": "1.19.1",
37
37
  "cookie-parser": "^1.4.6",
38
38
  "express": "4.17.2"
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "52bc37e7a570806c121b33a0e8ac1cd084445f5d"
48
+ "gitHead": "c2a37dd026c7bf3e855f4498691f572ef61396e3"
49
49
  }
package/dist/logger.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { MidwayContextLogger } from '@midwayjs/logger';
2
- import { Context } from './interface';
3
- export declare class MidwayExpressContextLogger extends MidwayContextLogger<Context> {
4
- formatContextLabel(): string;
5
- }
6
- //# sourceMappingURL=logger.d.ts.map
package/dist/logger.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MidwayExpressContextLogger = void 0;
4
- const logger_1 = require("@midwayjs/logger");
5
- class MidwayExpressContextLogger extends logger_1.MidwayContextLogger {
6
- formatContextLabel() {
7
- var _a;
8
- const req = this.ctx;
9
- // format: '[$userId/$ip/$traceId/$use_ms $method $url]'
10
- const userId = ((_a = req === null || req === void 0 ? void 0 : req['session']) === null || _a === void 0 ? void 0 : _a['userId']) || '-';
11
- const traceId = '-';
12
- const use = Date.now() - this.ctx.startTime;
13
- return (userId +
14
- '/' +
15
- req.ip +
16
- '/' +
17
- traceId +
18
- '/' +
19
- use +
20
- 'ms ' +
21
- req.method +
22
- ' ' +
23
- req.url);
24
- }
25
- }
26
- exports.MidwayExpressContextLogger = MidwayExpressContextLogger;
27
- //# sourceMappingURL=logger.js.map