@midwayjs/core 3.14.11 → 3.15.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.
@@ -92,28 +92,24 @@ class BaseFramework {
92
92
  return this.app;
93
93
  }
94
94
  createContextLogger(ctx, name) {
95
- const appLogger = this.getLogger(name !== null && name !== void 0 ? name : this.contextLoggerApplyLogger);
96
- if (name) {
95
+ if (name && name !== 'appLogger') {
96
+ const appLogger = this.getLogger(name);
97
97
  let ctxLoggerCache = ctx.getAttr(constants_1.REQUEST_CTX_LOGGER_CACHE_KEY);
98
98
  if (!ctxLoggerCache) {
99
99
  ctxLoggerCache = new Map();
100
100
  ctx.setAttr(constants_1.REQUEST_CTX_LOGGER_CACHE_KEY, ctxLoggerCache);
101
101
  }
102
- if (!name) {
103
- name = 'appLogger';
104
- }
105
102
  // if logger exists
106
103
  if (ctxLoggerCache.has(name)) {
107
104
  return ctxLoggerCache.get(name);
108
105
  }
109
106
  // create new context logger
110
- const ctxLogger = this.loggerService.createContextLogger(ctx, appLogger, {
111
- contextFormat: this.contextLoggerFormat,
112
- });
107
+ const ctxLogger = this.loggerService.createContextLogger(ctx, appLogger);
113
108
  ctxLoggerCache.set(name, ctxLogger);
114
109
  return ctxLogger;
115
110
  }
116
111
  else {
112
+ const appLogger = this.getLogger(name !== null && name !== void 0 ? name : this.contextLoggerApplyLogger);
117
113
  // avoid maximum call stack size exceeded
118
114
  if (ctx['_logger']) {
119
115
  return ctx['_logger'];
@@ -379,11 +375,5 @@ __decorate([
379
375
  __metadata("design:paramtypes", []),
380
376
  __metadata("design:returntype", Promise)
381
377
  ], BaseFramework.prototype, "init", null);
382
- __decorate([
383
- (0, decorator_1.Destroy)(),
384
- __metadata("design:type", Function),
385
- __metadata("design:paramtypes", []),
386
- __metadata("design:returntype", Promise)
387
- ], BaseFramework.prototype, "stop", null);
388
378
  exports.BaseFramework = BaseFramework;
389
379
  //# sourceMappingURL=baseFramework.js.map
@@ -28,7 +28,7 @@ export declare class DefaultConsoleLoggerFactory implements LoggerFactory<ILogge
28
28
  };
29
29
  };
30
30
  };
31
- createContextLogger(ctx: any, appLogger: ILogger): ILogger;
31
+ createContextLogger(ctx: any, appLogger: ILogger, contextOptions?: any): ILogger;
32
32
  getClients(): Map<string, ILogger>;
33
33
  getClientKeys(): string[];
34
34
  }
@@ -28,7 +28,7 @@ class DefaultConsoleLoggerFactory {
28
28
  },
29
29
  };
30
30
  }
31
- createContextLogger(ctx, appLogger) {
31
+ createContextLogger(ctx, appLogger, contextOptions) {
32
32
  return appLogger;
33
33
  }
34
34
  getClients() {
@@ -14,7 +14,7 @@ export declare abstract class ServiceFactory<T> implements IServiceFactory<T> {
14
14
  createInstance(config: any, clientName?: any): Promise<T | undefined>;
15
15
  abstract getName(): string;
16
16
  protected abstract createClient(config: any, clientName: any): Promise<T | void> | (T | void);
17
- protected destroyClient(client: T): Promise<void>;
17
+ protected destroyClient(client: T, clientName?: string): Promise<void>;
18
18
  stop(): Promise<void>;
19
19
  getDefaultClientName(): string;
20
20
  getClients(): Map<string, T>;
@@ -55,10 +55,10 @@ class ServiceFactory {
55
55
  return client;
56
56
  }
57
57
  }
58
- async destroyClient(client) { }
58
+ async destroyClient(client, clientName) { }
59
59
  async stop() {
60
- for (const value of this.clients.values()) {
61
- await this.destroyClient(value);
60
+ for (const [name, value] of this.clients.entries()) {
61
+ await this.destroyClient(value, name);
62
62
  }
63
63
  }
64
64
  getDefaultClientName() {
@@ -19,18 +19,16 @@ var RouteParamTypes;
19
19
  RouteParamTypes["CUSTOM"] = "custom";
20
20
  })(RouteParamTypes = exports.RouteParamTypes || (exports.RouteParamTypes = {}));
21
21
  const createParamMapping = function (type) {
22
- return (propertyOrPipes, pipes) => {
22
+ return (propertyOrPipes, options = {}) => {
23
23
  let propertyData = propertyOrPipes;
24
- if (Array.isArray(propertyOrPipes) && pipes === undefined) {
25
- pipes = propertyOrPipes;
24
+ if (Array.isArray(propertyOrPipes) && options.pipes === undefined) {
25
+ options.pipes = propertyOrPipes;
26
26
  propertyData = undefined;
27
27
  }
28
28
  return (0, __1.createCustomParamDecorator)(__1.WEB_ROUTER_PARAM_KEY, {
29
29
  type,
30
30
  propertyData,
31
- }, {
32
- pipes,
33
- });
31
+ }, options);
34
32
  };
35
33
  };
36
34
  const createRequestParamDecorator = function (transform, pipesOrOptions) {
@@ -40,29 +38,29 @@ const createRequestParamDecorator = function (transform, pipesOrOptions) {
40
38
  pipes: pipesOrOptions,
41
39
  };
42
40
  }
43
- return createParamMapping(RouteParamTypes.CUSTOM)(transform, pipesOrOptions.pipes);
41
+ return createParamMapping(RouteParamTypes.CUSTOM)(transform, pipesOrOptions);
44
42
  };
45
43
  exports.createRequestParamDecorator = createRequestParamDecorator;
46
- const Session = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.SESSION)(propertyOrPipes, pipes);
44
+ const Session = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.SESSION)(propertyOrPipes, { pipes });
47
45
  exports.Session = Session;
48
- const Body = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.BODY)(propertyOrPipes, pipes);
46
+ const Body = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.BODY)(propertyOrPipes, { pipes });
49
47
  exports.Body = Body;
50
- const Query = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.QUERY)(propertyOrPipes, pipes);
48
+ const Query = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.QUERY)(propertyOrPipes, { pipes });
51
49
  exports.Query = Query;
52
- const Param = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.PARAM)(propertyOrPipes, pipes);
50
+ const Param = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.PARAM)(propertyOrPipes, { pipes });
53
51
  exports.Param = Param;
54
- const Headers = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.HEADERS)(propertyOrPipes, pipes);
52
+ const Headers = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.HEADERS)(propertyOrPipes, { pipes });
55
53
  exports.Headers = Headers;
56
- const File = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.FILESTREAM)(propertyOrPipes, pipes);
54
+ const File = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.FILESTREAM)(propertyOrPipes, { pipes });
57
55
  exports.File = File;
58
- const Files = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.FILESSTREAM)(propertyOrPipes, pipes);
56
+ const Files = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.FILESSTREAM)(propertyOrPipes, { pipes });
59
57
  exports.Files = Files;
60
- const RequestPath = (pipes) => createParamMapping(RouteParamTypes.REQUEST_PATH)(undefined, pipes);
58
+ const RequestPath = (pipes) => createParamMapping(RouteParamTypes.REQUEST_PATH)(undefined, { pipes });
61
59
  exports.RequestPath = RequestPath;
62
- const RequestIP = (pipes) => createParamMapping(RouteParamTypes.REQUEST_IP)(undefined, pipes);
60
+ const RequestIP = (pipes) => createParamMapping(RouteParamTypes.REQUEST_IP)(undefined, { pipes });
63
61
  exports.RequestIP = RequestIP;
64
- const Queries = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.QUERIES)(propertyOrPipes, pipes);
62
+ const Queries = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.QUERIES)(propertyOrPipes, { pipes });
65
63
  exports.Queries = Queries;
66
- const Fields = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.FIELDS)(propertyOrPipes, pipes);
64
+ const Fields = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.FIELDS)(propertyOrPipes, { pipes });
67
65
  exports.Fields = Fields;
68
66
  //# sourceMappingURL=paramMapping.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.14.11",
3
+ "version": "3.15.0",
4
4
  "description": "midway core",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -42,5 +42,5 @@
42
42
  "engines": {
43
43
  "node": ">=12"
44
44
  },
45
- "gitHead": "a24b455e0b55cda9563236b35f9b49b600920642"
45
+ "gitHead": "be0a091f940aa60965d9fabfbdcbf0fe2830e9c4"
46
46
  }