@nocobase/server 0.9.2-alpha.4 → 0.9.4-alpha.1

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.
@@ -6,6 +6,8 @@ declare type AppSelector = (req: IncomingMessage) => AppSelectorReturn | Promise
6
6
  export declare class AppManager {
7
7
  applications: Map<string, Application>;
8
8
  app: Application;
9
+ runningMode: 'single' | 'multiple';
10
+ singleAppName: string | null;
9
11
  constructor(app: Application);
10
12
  bindMainApplication(mainApp: Application): void;
11
13
  appSelector: AppSelector;
@@ -22,6 +22,8 @@ class AppManager {
22
22
  var _this = this;
23
23
  this.applications = new Map();
24
24
  this.app = void 0;
25
+ this.runningMode = 'multiple';
26
+ this.singleAppName = null;
25
27
  this.appSelector = /*#__PURE__*/function () {
26
28
  var _ref = _asyncToGenerator(function* (req) {
27
29
  return _this.app;
@@ -31,6 +33,11 @@ class AppManager {
31
33
  };
32
34
  }();
33
35
  this.bindMainApplication(app);
36
+ // if STARTUP_SUBAPP is set, run in single mode
37
+ if (process.env.STARTUP_SUBAPP) {
38
+ this.singleAppName = process.env.STARTUP_SUBAPP;
39
+ this.runningMode = 'single';
40
+ }
34
41
  }
35
42
  bindMainApplication(mainApp) {
36
43
  var _this2 = this;
@@ -101,7 +108,12 @@ class AppManager {
101
108
  return /*#__PURE__*/function () {
102
109
  var _ref3 = _asyncToGenerator(function* (req, res) {
103
110
  const appManager = _this5.app.appManager;
104
- let handleApp = (yield appManager.appSelector(req)) || appManager.app;
111
+ let handleApp;
112
+ if (_this5.runningMode === 'single') {
113
+ handleApp = _this5.singleAppName;
114
+ } else {
115
+ handleApp = (yield appManager.appSelector(req)) || appManager.app;
116
+ }
105
117
  if (typeof handleApp === 'string') {
106
118
  handleApp = yield appManager.getApplication(handleApp);
107
119
  if (!handleApp) {
@@ -96,7 +96,7 @@ const traverseJSON = (data, options) => {
96
96
  include = _options$include === void 0 ? [] : _options$include;
97
97
  const map = parseInclude(include);
98
98
  const result = {};
99
- for (var _i = 0, _Object$keys = Object.keys(data); _i < _Object$keys.length; _i++) {
99
+ for (var _i = 0, _Object$keys = Object.keys(data || {}); _i < _Object$keys.length; _i++) {
100
100
  const key = _Object$keys[_i];
101
101
  const subInclude = map[key];
102
102
  if (include.length > 0 && !subInclude) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "0.9.2-alpha.4",
3
+ "version": "0.9.4-alpha.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -8,12 +8,12 @@
8
8
  "@hapi/topo": "^6.0.0",
9
9
  "@koa/cors": "^3.1.0",
10
10
  "@koa/router": "^9.4.0",
11
- "@nocobase/acl": "0.9.2-alpha.4",
12
- "@nocobase/actions": "0.9.2-alpha.4",
13
- "@nocobase/database": "0.9.2-alpha.4",
14
- "@nocobase/logger": "0.9.2-alpha.4",
15
- "@nocobase/resourcer": "0.9.2-alpha.4",
16
- "@nocobase/utils": "0.9.2-alpha.4",
11
+ "@nocobase/acl": "0.9.4-alpha.1",
12
+ "@nocobase/actions": "0.9.4-alpha.1",
13
+ "@nocobase/database": "0.9.4-alpha.1",
14
+ "@nocobase/logger": "0.9.4-alpha.1",
15
+ "@nocobase/resourcer": "0.9.4-alpha.1",
16
+ "@nocobase/utils": "0.9.4-alpha.1",
17
17
  "chalk": "^4.1.1",
18
18
  "commander": "^9.2.0",
19
19
  "find-package-json": "^1.2.0",
@@ -29,5 +29,5 @@
29
29
  "devDependencies": {
30
30
  "@types/semver": "^7.3.9"
31
31
  },
32
- "gitHead": "96cb023f353a4fb099dea074c575be65ebab813f"
32
+ "gitHead": "0b4936be557be918dbdf8196dadcbc7eb395906d"
33
33
  }