@nocobase/server 0.7.0-alpha.8 → 0.7.0-alpha.82
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.
- package/lib/acl/available-action.js +37 -35
- package/lib/acl/index.js +45 -21
- package/lib/app-manager.d.ts +3 -3
- package/lib/app-manager.js +151 -72
- package/lib/application.d.ts +3 -2
- package/lib/application.js +291 -153
- package/lib/commands/console.d.ts +2 -3
- package/lib/commands/console.js +33 -24
- package/lib/commands/db-auth.d.ts +3 -0
- package/lib/commands/db-auth.js +26 -0
- package/lib/commands/db-clean.d.ts +3 -0
- package/lib/commands/db-clean.js +27 -0
- package/lib/commands/db-sync.d.ts +2 -4
- package/lib/commands/db-sync.js +25 -23
- package/lib/commands/index.d.ts +1 -2
- package/lib/commands/index.js +29 -29
- package/lib/commands/install.d.ts +2 -4
- package/lib/commands/install.js +68 -20
- package/lib/commands/start.d.ts +2 -4
- package/lib/commands/start.js +28 -22
- package/lib/commands/upgrade.d.ts +6 -0
- package/lib/commands/upgrade.js +45 -0
- package/lib/helper.js +132 -61
- package/lib/index.js +85 -32
- package/lib/middlewares/data-wrapping.js +65 -55
- package/lib/middlewares/index.js +30 -14
- package/lib/middlewares/table2resource.js +89 -52
- package/lib/plugin-manager.js +124 -55
- package/lib/plugin.js +65 -45
- package/lib/read-config.js +159 -64
- package/package.json +8 -13
- package/esm/acl/available-action.d.ts +0 -5
- package/esm/acl/available-action.js +0 -36
- package/esm/acl/available-action.js.map +0 -1
- package/esm/acl/index.d.ts +0 -2
- package/esm/acl/index.js +0 -19
- package/esm/acl/index.js.map +0 -1
- package/esm/app-manager.d.ts +0 -19
- package/esm/app-manager.js +0 -69
- package/esm/app-manager.js.map +0 -1
- package/esm/application.d.ts +0 -97
- package/esm/application.js +0 -156
- package/esm/application.js.map +0 -1
- package/esm/commands/console.d.ts +0 -4
- package/esm/commands/console.js +0 -25
- package/esm/commands/console.js.map +0 -1
- package/esm/commands/create-plugin/create-plugin.d.ts +0 -2
- package/esm/commands/create-plugin/create-plugin.js +0 -29
- package/esm/commands/create-plugin/create-plugin.js.map +0 -1
- package/esm/commands/create-plugin/index.d.ts +0 -5
- package/esm/commands/create-plugin/index.js +0 -6
- package/esm/commands/create-plugin/index.js.map +0 -1
- package/esm/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
- package/esm/commands/create-plugin/resources/templates/package-json.js +0 -11
- package/esm/commands/create-plugin/resources/templates/package-json.js.map +0 -1
- package/esm/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
- package/esm/commands/create-plugin/resources/templates/plugin.js +0 -12
- package/esm/commands/create-plugin/resources/templates/plugin.js.map +0 -1
- package/esm/commands/db-sync.d.ts +0 -5
- package/esm/commands/db-sync.js +0 -25
- package/esm/commands/db-sync.js.map +0 -1
- package/esm/commands/index.d.ts +0 -3
- package/esm/commands/index.js +0 -26
- package/esm/commands/index.js.map +0 -1
- package/esm/commands/install.d.ts +0 -5
- package/esm/commands/install.js +0 -23
- package/esm/commands/install.js.map +0 -1
- package/esm/commands/start.d.ts +0 -5
- package/esm/commands/start.js +0 -23
- package/esm/commands/start.js.map +0 -1
- package/esm/helper.d.ts +0 -7
- package/esm/helper.js +0 -59
- package/esm/helper.js.map +0 -1
- package/esm/index.d.ts +0 -7
- package/esm/index.js +0 -9
- package/esm/index.js.map +0 -1
- package/esm/middlewares/data-wrapping.d.ts +0 -3
- package/esm/middlewares/data-wrapping.js +0 -54
- package/esm/middlewares/data-wrapping.js.map +0 -1
- package/esm/middlewares/index.d.ts +0 -2
- package/esm/middlewares/index.js +0 -3
- package/esm/middlewares/index.js.map +0 -1
- package/esm/middlewares/table2resource.d.ts +0 -6
- package/esm/middlewares/table2resource.js +0 -51
- package/esm/middlewares/table2resource.js.map +0 -1
- package/esm/plugin-manager.d.ts +0 -23
- package/esm/plugin-manager.js +0 -57
- package/esm/plugin-manager.js.map +0 -1
- package/esm/plugin.d.ts +0 -32
- package/esm/plugin.js +0 -43
- package/esm/plugin.js.map +0 -1
- package/esm/read-config.d.ts +0 -8
- package/esm/read-config.js +0 -63
- package/esm/read-config.js.map +0 -1
- package/lib/acl/available-action.js.map +0 -1
- package/lib/acl/index.js.map +0 -1
- package/lib/app-manager.js.map +0 -1
- package/lib/application.js.map +0 -1
- package/lib/commands/console.js.map +0 -1
- package/lib/commands/create-plugin/create-plugin.d.ts +0 -2
- package/lib/commands/create-plugin/create-plugin.js +0 -31
- package/lib/commands/create-plugin/create-plugin.js.map +0 -1
- package/lib/commands/create-plugin/index.d.ts +0 -5
- package/lib/commands/create-plugin/index.js +0 -8
- package/lib/commands/create-plugin/index.js.map +0 -1
- package/lib/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
- package/lib/commands/create-plugin/resources/templates/package-json.js +0 -13
- package/lib/commands/create-plugin/resources/templates/package-json.js.map +0 -1
- package/lib/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
- package/lib/commands/create-plugin/resources/templates/plugin.js +0 -33
- package/lib/commands/create-plugin/resources/templates/plugin.js.map +0 -1
- package/lib/commands/db-sync.js.map +0 -1
- package/lib/commands/index.js.map +0 -1
- package/lib/commands/install.js.map +0 -1
- package/lib/commands/start.js.map +0 -1
- package/lib/helper.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/middlewares/data-wrapping.js.map +0 -1
- package/lib/middlewares/index.js.map +0 -1
- package/lib/middlewares/table2resource.js.map +0 -1
- package/lib/plugin-manager.js.map +0 -1
- package/lib/plugin.js.map +0 -1
- package/lib/read-config.js.map +0 -1
- package/tsconfig.build.json +0 -9
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
3
6
|
exports.availableActions = void 0;
|
|
4
7
|
const availableActions = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
8
|
+
create: {
|
|
9
|
+
displayName: '{{t("Add new")}}',
|
|
10
|
+
type: 'new-data',
|
|
11
|
+
onNewRecord: true,
|
|
12
|
+
allowConfigureFields: true
|
|
13
|
+
},
|
|
14
|
+
// import: {
|
|
15
|
+
// displayName: '{{t("Import")}}',
|
|
16
|
+
// type: 'new-data',
|
|
17
|
+
// scope: false,
|
|
18
|
+
// },
|
|
19
|
+
// export: {
|
|
20
|
+
// displayName: '{{t("Export")}}',
|
|
21
|
+
// type: 'old-data',
|
|
22
|
+
// allowConfigureFields: true,
|
|
23
|
+
// },
|
|
24
|
+
view: {
|
|
25
|
+
displayName: '{{t("View")}}',
|
|
26
|
+
type: 'old-data',
|
|
27
|
+
aliases: ['get', 'list'],
|
|
28
|
+
allowConfigureFields: true
|
|
29
|
+
},
|
|
30
|
+
update: {
|
|
31
|
+
displayName: '{{t("Edit")}}',
|
|
32
|
+
type: 'old-data',
|
|
33
|
+
aliases: ['update', 'move'],
|
|
34
|
+
allowConfigureFields: true
|
|
35
|
+
},
|
|
36
|
+
destroy: {
|
|
37
|
+
displayName: '{{t("Delete")}}',
|
|
38
|
+
type: 'old-data'
|
|
39
|
+
}
|
|
37
40
|
};
|
|
38
|
-
exports.availableActions = availableActions;
|
|
39
|
-
//# sourceMappingURL=available-action.js.map
|
|
41
|
+
exports.availableActions = availableActions;
|
package/lib/acl/index.js
CHANGED
|
@@ -1,23 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const configureResources = [
|
|
7
|
-
'roles',
|
|
8
|
-
'collections',
|
|
9
|
-
'roles.collections',
|
|
10
|
-
'roles.resources',
|
|
11
|
-
'rolesResourcesScopes',
|
|
12
|
-
'availableActions',
|
|
13
|
-
];
|
|
14
|
-
function createACL() {
|
|
15
|
-
const acl = new acl_1.ACL();
|
|
16
|
-
for (const [actionName, actionParams] of Object.entries(available_action_1.availableActions)) {
|
|
17
|
-
acl.setAvailableAction(actionName, actionParams);
|
|
18
|
-
}
|
|
19
|
-
acl.registerConfigResources(configureResources);
|
|
20
|
-
return acl;
|
|
21
|
-
}
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
22
6
|
exports.createACL = createACL;
|
|
23
|
-
|
|
7
|
+
|
|
8
|
+
function _acl() {
|
|
9
|
+
const data = require("@nocobase/acl");
|
|
10
|
+
|
|
11
|
+
_acl = function _acl() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var _availableAction = require("./available-action");
|
|
19
|
+
|
|
20
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
21
|
+
|
|
22
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
|
+
|
|
24
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
+
|
|
26
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
27
|
+
|
|
28
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
29
|
+
|
|
30
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
|
+
|
|
32
|
+
const configureResources = ['roles', 'collections', 'roles.collections', 'roles.resources', 'rolesResourcesScopes', 'availableActions'];
|
|
33
|
+
|
|
34
|
+
function createACL() {
|
|
35
|
+
const acl = new (_acl().ACL)();
|
|
36
|
+
|
|
37
|
+
for (var _i = 0, _Object$entries = Object.entries(_availableAction.availableActions); _i < _Object$entries.length; _i++) {
|
|
38
|
+
const _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
39
|
+
actionName = _Object$entries$_i[0],
|
|
40
|
+
actionParams = _Object$entries$_i[1];
|
|
41
|
+
|
|
42
|
+
acl.setAvailableAction(actionName, actionParams);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
acl.registerConfigResources(configureResources);
|
|
46
|
+
return acl;
|
|
47
|
+
}
|
package/lib/app-manager.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import Application, { ApplicationOptions } from './application';
|
|
3
|
-
import http, { IncomingMessage } from 'http';
|
|
4
2
|
import EventEmitter from 'events';
|
|
3
|
+
import http, { IncomingMessage, ServerResponse } from 'http';
|
|
4
|
+
import Application, { ApplicationOptions } from './application';
|
|
5
5
|
declare type AppSelector = (req: IncomingMessage) => Application | string | undefined | null;
|
|
6
6
|
export declare class AppManager extends EventEmitter {
|
|
7
7
|
private app;
|
|
@@ -13,7 +13,7 @@ export declare class AppManager extends EventEmitter {
|
|
|
13
13
|
setAppSelector(selector: AppSelector): void;
|
|
14
14
|
listen(...args: any[]): http.Server;
|
|
15
15
|
getApplication(appName: string): Promise<null | Application>;
|
|
16
|
-
callback(): (req:
|
|
16
|
+
callback(): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
17
17
|
emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
|
|
18
18
|
}
|
|
19
19
|
export {};
|
package/lib/app-manager.js
CHANGED
|
@@ -1,76 +1,155 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
15
6
|
exports.AppManager = void 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.appSelector = (req) => this.app;
|
|
26
|
-
app.on('beforeStop', (mainApp, options) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
return yield Promise.all([...this.applications.values()].map((application) => application.stop(options)));
|
|
28
|
-
}));
|
|
29
|
-
app.on('afterDestroy', (mainApp, options) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
return yield Promise.all([...this.applications.values()].map((application) => application.destroy(options)));
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
createApplication(name, options) {
|
|
34
|
-
const application = new application_1.default(options);
|
|
35
|
-
this.applications.set(name, application);
|
|
36
|
-
return application;
|
|
37
|
-
}
|
|
38
|
-
removeApplication(name) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const application = this.applications.get(name);
|
|
41
|
-
if (!application) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
yield application.destroy();
|
|
45
|
-
this.applications.delete(name);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
setAppSelector(selector) {
|
|
49
|
-
this.appSelector = selector;
|
|
50
|
-
}
|
|
51
|
-
listen(...args) {
|
|
52
|
-
const server = http_1.default.createServer(this.callback());
|
|
53
|
-
return server.listen(...args);
|
|
54
|
-
}
|
|
55
|
-
getApplication(appName) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
yield this.emitAsync('beforeGetApplication', {
|
|
58
|
-
appManager: this,
|
|
59
|
-
name: appName,
|
|
60
|
-
});
|
|
61
|
-
return this.applications.get(appName);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
callback() {
|
|
65
|
-
return (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
let handleApp = this.appSelector(req) || this.app;
|
|
67
|
-
if (typeof handleApp === 'string') {
|
|
68
|
-
handleApp = (yield this.getApplication(handleApp)) || this.app;
|
|
69
|
-
}
|
|
70
|
-
handleApp.callback()(req, res);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
7
|
+
|
|
8
|
+
function _utils() {
|
|
9
|
+
const data = require("@nocobase/utils");
|
|
10
|
+
|
|
11
|
+
_utils = function _utils() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
73
16
|
}
|
|
17
|
+
|
|
18
|
+
function _events() {
|
|
19
|
+
const data = _interopRequireDefault(require("events"));
|
|
20
|
+
|
|
21
|
+
_events = function _events() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _http() {
|
|
29
|
+
const data = _interopRequireDefault(require("http"));
|
|
30
|
+
|
|
31
|
+
_http = function _http() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var _application = _interopRequireDefault(require("./application"));
|
|
39
|
+
|
|
40
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
|
+
|
|
42
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
43
|
+
|
|
44
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
45
|
+
|
|
46
|
+
class AppManager extends _events().default {
|
|
47
|
+
constructor(app) {
|
|
48
|
+
var _this;
|
|
49
|
+
|
|
50
|
+
super();
|
|
51
|
+
_this = this;
|
|
52
|
+
this.app = void 0;
|
|
53
|
+
this.applications = new Map();
|
|
54
|
+
|
|
55
|
+
this.appSelector = req => this.app;
|
|
56
|
+
|
|
57
|
+
this.app = app;
|
|
58
|
+
app.on('beforeStop', /*#__PURE__*/function () {
|
|
59
|
+
var _ref = _asyncToGenerator(function* (mainApp, options) {
|
|
60
|
+
return yield Promise.all([..._this.applications.values()].map(application => application.stop(options)));
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return function (_x, _x2) {
|
|
64
|
+
return _ref.apply(this, arguments);
|
|
65
|
+
};
|
|
66
|
+
}());
|
|
67
|
+
app.on('afterDestroy', /*#__PURE__*/function () {
|
|
68
|
+
var _ref2 = _asyncToGenerator(function* (mainApp, options) {
|
|
69
|
+
return yield Promise.all([..._this.applications.values()].map(application => application.destroy(options)));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return function (_x3, _x4) {
|
|
73
|
+
return _ref2.apply(this, arguments);
|
|
74
|
+
};
|
|
75
|
+
}());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
createApplication(name, options) {
|
|
79
|
+
const application = new _application.default(options);
|
|
80
|
+
this.applications.set(name, application);
|
|
81
|
+
return application;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
removeApplication(name) {
|
|
85
|
+
var _this2 = this;
|
|
86
|
+
|
|
87
|
+
return _asyncToGenerator(function* () {
|
|
88
|
+
const application = _this2.applications.get(name);
|
|
89
|
+
|
|
90
|
+
if (!application) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
yield application.destroy();
|
|
95
|
+
|
|
96
|
+
_this2.applications.delete(name);
|
|
97
|
+
})();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setAppSelector(selector) {
|
|
101
|
+
this.appSelector = selector;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
listen(...args) {
|
|
105
|
+
const server = _http().default.createServer(this.callback());
|
|
106
|
+
|
|
107
|
+
return server.listen(...args);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getApplication(appName) {
|
|
111
|
+
var _this3 = this;
|
|
112
|
+
|
|
113
|
+
return _asyncToGenerator(function* () {
|
|
114
|
+
yield _this3.emitAsync('beforeGetApplication', {
|
|
115
|
+
appManager: _this3,
|
|
116
|
+
name: appName
|
|
117
|
+
});
|
|
118
|
+
return _this3.applications.get(appName);
|
|
119
|
+
})();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
callback() {
|
|
123
|
+
var _this4 = this;
|
|
124
|
+
|
|
125
|
+
return /*#__PURE__*/function () {
|
|
126
|
+
var _ref3 = _asyncToGenerator(function* (req, res) {
|
|
127
|
+
let handleApp = _this4.appSelector(req) || _this4.app;
|
|
128
|
+
|
|
129
|
+
if (typeof handleApp === 'string') {
|
|
130
|
+
handleApp = yield _this4.getApplication(handleApp);
|
|
131
|
+
|
|
132
|
+
if (!handleApp) {
|
|
133
|
+
res.statusCode = 404;
|
|
134
|
+
return res.end(JSON.stringify({
|
|
135
|
+
redirectTo: process.env.APP_NOT_FOUND_REDIRECT_TO,
|
|
136
|
+
errors: [{
|
|
137
|
+
message: 'Not Found'
|
|
138
|
+
}]
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
handleApp.callback()(req, res);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return function (_x5, _x6) {
|
|
147
|
+
return _ref3.apply(this, arguments);
|
|
148
|
+
};
|
|
149
|
+
}();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
74
154
|
exports.AppManager = AppManager;
|
|
75
|
-
(0,
|
|
76
|
-
//# sourceMappingURL=app-manager.js.map
|
|
155
|
+
(0, _utils().applyMixins)(AppManager, [_utils().AsyncEmitter]);
|
package/lib/application.d.ts
CHANGED
|
@@ -26,11 +26,11 @@ export interface ApplicationOptions {
|
|
|
26
26
|
i18n?: i18n | InitOptions;
|
|
27
27
|
plugins?: PluginsConfigurations;
|
|
28
28
|
}
|
|
29
|
-
interface DefaultState {
|
|
29
|
+
export interface DefaultState {
|
|
30
30
|
currentUser?: any;
|
|
31
31
|
[key: string]: any;
|
|
32
32
|
}
|
|
33
|
-
interface DefaultContext {
|
|
33
|
+
export interface DefaultContext {
|
|
34
34
|
db: Database;
|
|
35
35
|
resourcer: Resourcer;
|
|
36
36
|
[key: string]: any;
|
|
@@ -76,6 +76,7 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
76
76
|
protected plugins: Map<string, Plugin<any>>;
|
|
77
77
|
listenServer: Server;
|
|
78
78
|
constructor(options: ApplicationOptions);
|
|
79
|
+
getVersion(): any;
|
|
79
80
|
plugin<O = any>(pluginClass: any, options?: O): Plugin<O>;
|
|
80
81
|
loadPluginConfig(pluginsConfigurations: PluginsConfigurations): void;
|
|
81
82
|
use<NewStateT = {}, NewContextT = {}>(middleware: Koa.Middleware<StateT & NewStateT, ContextT & NewContextT>, options?: MiddlewareOptions): Koa<Koa.DefaultState & StateT & NewStateT, Koa.DefaultContext & ContextT & NewContextT>;
|