@midwayjs/core 3.4.11 → 3.4.12

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,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ServiceFactory = void 0;
4
- const assert = require("assert");
5
4
  const extend_1 = require("../util/extend");
6
5
  /**
7
6
  * 多客户端工厂实现
@@ -13,13 +12,14 @@ class ServiceFactory {
13
12
  }
14
13
  async initClients(options = {}) {
15
14
  this.options = options;
16
- assert(!(options.client && options.clients), `midway:${this.getName()} can not set options.client and options.clients both`);
17
- // alias app[name] as client, but still support createInstance method
15
+ // merge options.client to options.clients['default']
18
16
  if (options.client) {
19
- await this.createInstance(options.client, 'default');
20
- return;
17
+ options.clients = options.clients || {};
18
+ options.clients['default'] = options.clients['default'] || {};
19
+ (0, extend_1.extend)(true, options.clients['default'], options.client);
20
+ delete options.client;
21
21
  }
22
- // multi client, use app[name].getInstance(id)
22
+ // multi client
23
23
  if (options.clients) {
24
24
  for (const id of Object.keys(options.clients)) {
25
25
  await this.createInstance(options.clients[id], id);
@@ -10,7 +10,7 @@ export declare class MidwayConfigService implements IConfigService {
10
10
  private envDirMap;
11
11
  private aliasMap;
12
12
  private configMergeOrder;
13
- protected configuration: any;
13
+ protected configuration: {};
14
14
  protected isReady: boolean;
15
15
  protected externalObject: Record<string, unknown>[];
16
16
  protected appInfo: MidwayAppInfo;
@@ -28,6 +28,7 @@ let MidwayConfigService = class MidwayConfigService {
28
28
  unittest: 'test',
29
29
  };
30
30
  this.configMergeOrder = [];
31
+ this.configuration = {};
31
32
  this.isReady = false;
32
33
  this.externalObject = [];
33
34
  this.configFilterList = [];
@@ -161,6 +162,10 @@ let MidwayConfigService = class MidwayConfigService {
161
162
  for (let externalObject of this.externalObject) {
162
163
  if (externalObject) {
163
164
  externalObject = this.runWithFilter(externalObject);
165
+ if (!externalObject) {
166
+ debug('[config]: Filter config and got undefined will be drop it');
167
+ continue;
168
+ }
164
169
  debug('[config]: Loaded external object %j', externalObject);
165
170
  (0, extend_1.extend)(true, target, externalObject);
166
171
  this.configMergeOrder.push({
@@ -199,7 +204,7 @@ let MidwayConfigService = class MidwayConfigService {
199
204
  return exports;
200
205
  }
201
206
  clearAllConfig() {
202
- this.configuration.clear();
207
+ this.configuration = {};
203
208
  }
204
209
  clearConfigMergeOrder() {
205
210
  this.configMergeOrder.length = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.4.11",
3
+ "version": "3.4.12",
4
4
  "description": "midway core",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "942dd076d60f27d6004640fa6dd9a9724efc559d"
48
+ "gitHead": "96425bbb3a39dbe8f66069facc5b7440886f9cfe"
49
49
  }