taon 19.0.50 → 19.0.52
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/browser/fesm2022/taon.mjs +167 -77
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-context.d.ts +1 -0
- package/browser/lib/base-classes/base-controller.d.ts +0 -6
- package/browser/lib/base-classes/base-injector.d.ts +4 -5
- package/browser/lib/base-classes/base-middleware.d.ts +17 -0
- package/browser/lib/base-classes/base.d.ts +3 -0
- package/browser/lib/constants.d.ts +1 -1
- package/browser/lib/create-context.d.ts +4 -2
- package/browser/lib/decorators/classes/middleware-decorator.d.ts +8 -0
- package/browser/lib/endpoint-context.d.ts +6 -5
- package/browser/lib/index.d.ts +8 -2
- package/browser/lib/models.d.ts +65 -5
- package/browser/package.json +1 -1
- package/lib/base-classes/base-context.d.ts +1 -0
- package/lib/base-classes/base-controller.d.ts +0 -6
- package/lib/base-classes/base-controller.js +0 -8
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base-injector.d.ts +4 -5
- package/lib/base-classes/base-injector.js +6 -7
- package/lib/base-classes/base-injector.js.map +1 -1
- package/lib/base-classes/base-middleware.d.ts +20 -0
- package/lib/base-classes/base-middleware.js +13 -0
- package/lib/base-classes/base-middleware.js.map +1 -0
- package/lib/base-classes/base.d.ts +3 -0
- package/lib/base-classes/base.js +2 -0
- package/lib/base-classes/base.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +2 -3
- package/lib/constants.js.map +1 -1
- package/lib/create-context.d.ts +4 -2
- package/lib/create-context.js +40 -36
- package/lib/create-context.js.map +1 -1
- package/lib/decorators/classes/middleware-decorator.d.ts +7 -0
- package/lib/decorators/classes/middleware-decorator.js +21 -0
- package/lib/decorators/classes/middleware-decorator.js.map +1 -0
- package/lib/decorators/classes/provider-decorator.js +1 -1
- package/lib/decorators/classes/provider-decorator.js.map +1 -1
- package/lib/endpoint-context.d.ts +6 -5
- package/lib/endpoint-context.js +79 -29
- package/lib/endpoint-context.js.map +1 -1
- package/lib/env/env.angular-node-app.d.ts +1 -0
- package/lib/env/env.angular-node-app.js +3 -2
- package/lib/env/env.angular-node-app.js.map +1 -1
- package/lib/env/env.docs-webapp.d.ts +1 -0
- package/lib/env/env.docs-webapp.js +3 -2
- package/lib/env/env.docs-webapp.js.map +1 -1
- package/lib/env/env.electron-app.d.ts +1 -0
- package/lib/env/env.electron-app.js +3 -2
- package/lib/env/env.electron-app.js.map +1 -1
- package/lib/env/env.mobile-app.d.ts +1 -0
- package/lib/env/env.mobile-app.js +3 -2
- package/lib/env/env.mobile-app.js.map +1 -1
- package/lib/env/env.npm-lib-and-cli-tool.d.ts +1 -0
- package/lib/env/env.npm-lib-and-cli-tool.js +3 -2
- package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib/env/env.vscode-plugin.d.ts +1 -0
- package/lib/env/env.vscode-plugin.js +3 -2
- package/lib/env/env.vscode-plugin.js.map +1 -1
- package/lib/env.js +1 -5
- package/lib/env.js.map +1 -1
- package/lib/index.d.ts +8 -2
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +65 -5
- package/lib/models.js +7 -5
- package/lib/models.js.map +1 -1
- package/lib/storage.d.ts +1 -1
- package/lib/storage.js +1 -5
- package/lib/storage.js.map +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/package.json +1 -1
- package/websql/fesm2022/taon.mjs +168 -78
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-context.d.ts +1 -0
- package/websql/lib/base-classes/base-controller.d.ts +0 -6
- package/websql/lib/base-classes/base-injector.d.ts +4 -5
- package/websql/lib/base-classes/base-middleware.d.ts +21 -0
- package/websql/lib/base-classes/base.d.ts +3 -0
- package/websql/lib/constants.d.ts +1 -1
- package/websql/lib/create-context.d.ts +4 -2
- package/websql/lib/decorators/classes/middleware-decorator.d.ts +8 -0
- package/websql/lib/endpoint-context.d.ts +6 -5
- package/websql/lib/index.d.ts +8 -2
- package/websql/lib/models.d.ts +65 -5
- package/websql/package.json +1 -1
- package/lib/base-classes/base-subscriber.d.ts +0 -4
- package/lib/base-classes/base-subscriber.js +0 -25
- package/lib/base-classes/base-subscriber.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.js +0 -214
- package/lib/realtime/realtime-strategy/realtime-abstract-mock.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.d.ts +0 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js +0 -5
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +0 -22
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js +0 -139
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +0 -16
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js +0 -68
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js +0 -56
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +0 -10
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js +0 -50
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +0 -13
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js +0 -3
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +0 -2
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js +0 -6
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +0 -16
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js +0 -54
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +0 -17
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js +0 -52
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +0 -11
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js +0 -39
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +0 -13
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js +0 -46
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js.map +0 -1
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +0 -11
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js +0 -3
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js.map +0 -1
- package/lib/ui/directives/firedev-inject-html.directive.d.ts +0 -6
- package/lib/ui/directives/firedev-long-press.directive.d.ts +0 -22
- package/lib/ui/directives/index.d.ts +0 -3
- package/lib/ui/directives/index.js +0 -5
- package/lib/ui/directives/index.js.map +0 -1
- package/lib/ui/directives/safe.pipe.d.ts +0 -7
- package/lib/ui/directives/taon-inject-html.directive.d.ts +0 -6
- package/lib/ui/directives/taon-long-press.directive.d.ts +0 -22
- package/lib/ui/directives/view-mode.d.ts +0 -5
- package/lib/ui/directives/view-mode.js +0 -10
- package/lib/ui/directives/view-mode.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +0 -29
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +0 -8
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +0 -5
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +0 -13
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +0 -5
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +0 -3
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +0 -1
- package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +0 -14
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +0 -43
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.module.d.ts +0 -2
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.d.ts +0 -5
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js +0 -3
- package/lib/ui/taon-admin-mode-configuration/taon-admin.models.js.map +0 -1
- package/lib/ui/taon-full-material.module.d.ts +0 -5
- package/lib/ui/taon-github-fork-me-corner/index.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-corner/index.js +0 -5
- package/lib/ui/taon-github-fork-me-corner/index.js.map +0 -1
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +0 -3
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +0 -2
- package/lib/ui/taon-github-fork-me-ribbon/index.js +0 -5
- package/lib/ui/taon-github-fork-me-ribbon/index.js.map +0 -1
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +0 -3
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +0 -2
- package/lib/ui/taon-notifications/index.d.ts +0 -4
- package/lib/ui/taon-notifications/index.js +0 -24
- package/lib/ui/taon-notifications/index.js.map +0 -1
- package/lib/ui/taon-notifications/taon-notifications.component.d.ts +0 -9
- package/lib/ui/taon-notifications/taon-notifications.models.d.ts +0 -6
- package/lib/ui/taon-notifications/taon-notifications.models.js +0 -5
- package/lib/ui/taon-notifications/taon-notifications.models.js.map +0 -1
- package/lib/ui/taon-notifications/taon-notifications.module.d.ts +0 -2
- package/lib/ui/taon-notifications/taon-notifications.service.d.ts +0 -11
- package/lib/ui/taon-progress-bar/index.d.ts +0 -2
- package/lib/ui/taon-progress-bar/index.js +0 -5
- package/lib/ui/taon-progress-bar/index.js.map +0 -1
- package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +0 -13
- package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +0 -2
- package/lib/ui/taon-session-passcode/index.d.ts +0 -1
- package/lib/ui/taon-session-passcode/index.js +0 -5
- package/lib/ui/taon-session-passcode/index.js.map +0 -1
- package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +0 -35
- package/lib/ui/taon-table/index.d.ts +0 -2
- package/lib/ui/taon-table/index.js +0 -5
- package/lib/ui/taon-table/index.js.map +0 -1
- package/lib/ui/taon-table/taon-table.component.d.ts +0 -34
- package/lib/ui/taon-table/taon-table.module.d.ts +0 -2
- package/lib/ui/taon.models.d.ts +0 -11
- package/lib/ui/taon.models.js +0 -3
- package/lib/ui/taon.models.js.map +0 -1
- package/lib/ui/toan-full-material.module.d.ts +0 -2
- package/tmp-environment.json +0 -43
package/lib/create-context.d.ts
CHANGED
|
@@ -5,13 +5,14 @@ import { Models } from './models';
|
|
|
5
5
|
* Context function can be used to dynamically
|
|
6
6
|
* create context with specific configuration.
|
|
7
7
|
*/
|
|
8
|
-
export declare const createContextTemplate: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION>) => () => {
|
|
8
|
+
export declare const createContextTemplate: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>, MIDDLEWARE extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION, MIDDLEWARE>) => () => {
|
|
9
9
|
types: {
|
|
10
10
|
readonly controllers: any;
|
|
11
11
|
readonly repositories: any;
|
|
12
12
|
readonly providers: any;
|
|
13
13
|
readonly subscribers: any;
|
|
14
14
|
readonly migrations: any;
|
|
15
|
+
readonly middlewares: any;
|
|
15
16
|
};
|
|
16
17
|
readonly contexts: any;
|
|
17
18
|
readonly contextName: string;
|
|
@@ -51,13 +52,14 @@ export declare const createContextTemplate: <CTX extends Record<string, object>,
|
|
|
51
52
|
* REQURIED PROPERTY:
|
|
52
53
|
* - contextName
|
|
53
54
|
*/
|
|
54
|
-
export declare const createContext: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION>) => {
|
|
55
|
+
export declare const createContext: <CTX extends Record<string, object>, CTRL extends Record<string, new (...args: any[]) => any>, ENTITY extends Record<string, new (...args: any[]) => any>, REPO extends Record<string, new (...args: any[]) => any>, PROVIDER extends Record<string, new (...args: any[]) => any>, SUBSCRIBER extends Record<string, new (...args: any[]) => any>, MIGRATION extends Record<string, new (...args: any[]) => any>, MIDDLEWARES extends Record<string, new (...args: any[]) => any>>(configFn: (env: any) => Models.ContextOptions<CTX, CTRL, ENTITY, REPO, PROVIDER, SUBSCRIBER, MIGRATION, MIDDLEWARES>) => {
|
|
55
56
|
types: {
|
|
56
57
|
readonly controllers: any;
|
|
57
58
|
readonly repositories: any;
|
|
58
59
|
readonly providers: any;
|
|
59
60
|
readonly subscribers: any;
|
|
60
61
|
readonly migrations: any;
|
|
62
|
+
readonly middlewares: any;
|
|
61
63
|
};
|
|
62
64
|
readonly contexts: any;
|
|
63
65
|
readonly contextName: string;
|
package/lib/create-context.js
CHANGED
|
@@ -65,6 +65,9 @@ const createContext = (configFn) => {
|
|
|
65
65
|
get migrations() {
|
|
66
66
|
return config.migrations; // TODO QUICK_FIX new typescript generated wrong types
|
|
67
67
|
},
|
|
68
|
+
get middlewares() {
|
|
69
|
+
return config.middlewares; // TODO QUICK_FIX new typescript generated wrong types
|
|
70
|
+
},
|
|
68
71
|
},
|
|
69
72
|
//#endregion
|
|
70
73
|
//#region contexts
|
|
@@ -159,42 +162,43 @@ const createContext = (configFn) => {
|
|
|
159
162
|
endpointContextRef.writeActiveRoutes();
|
|
160
163
|
//#endregion
|
|
161
164
|
await endpointContextRef.initClasses();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
!lib_1.
|
|
168
|
-
lib_1.
|
|
169
|
-
`
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
lib_1.
|
|
174
|
-
`
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
165
|
+
if (endpointContextRef.databaseConfig) {
|
|
166
|
+
let keepWebsqlDbDataAfterReload = false;
|
|
167
|
+
/* */
|
|
168
|
+
/* */
|
|
169
|
+
/* */
|
|
170
|
+
if (!lib_1.Helpers.isNode && keepWebsqlDbDataAfterReload) {
|
|
171
|
+
!lib_1.UtilsOs.isRunningInCliMode() &&
|
|
172
|
+
lib_1.Helpers.info(`[taon] Keeping websql data after reload ` +
|
|
173
|
+
`(context=${endpointContextRef.contextName}).`);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
!lib_1.UtilsOs.isRunningInCliMode() &&
|
|
177
|
+
lib_1.Helpers.info(`[taon] Dropping all tables and data ` +
|
|
178
|
+
`(context=${endpointContextRef.contextName}).`);
|
|
179
|
+
}
|
|
180
|
+
//#region TODO this may be usefull but for now
|
|
181
|
+
// 2 separate contexts are fine
|
|
182
|
+
// const shouldStartRemoteHost = endpointContextRef.mode !== 'remote-backend(tcp+udp)';
|
|
183
|
+
// if(shouldStartRemoteHost) {
|
|
184
|
+
// const endpointContextRemoteHostRef = new EndpointContext(config, configFn);
|
|
185
|
+
// await endpointContextRemoteHostRef.init({
|
|
186
|
+
// overrideRemoteHost: endpointContextRef.host,
|
|
187
|
+
// overrideHost: null,
|
|
188
|
+
// });
|
|
189
|
+
// endpointContextRemoteHostRef.initMetadata();
|
|
190
|
+
// endpointContextRef.__contextForControllerInstanceAccess = endpointContextRemoteHostRef;
|
|
191
|
+
// }
|
|
192
|
+
//#endregion
|
|
193
|
+
if (endpointContextRef.onlyMigrationRun) {
|
|
194
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
195
|
+
}
|
|
196
|
+
else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
|
|
197
|
+
await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
201
|
+
}
|
|
198
202
|
}
|
|
199
203
|
resolve(endpointContextRef);
|
|
200
204
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,sCAAmD;AAEnD,yDAAqD;AAErD,KAAK;AACL,YAAY;AAEZ;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,
|
|
1
|
+
{"version":3,"file":"create-context.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,sCAAmD;AAEnD,yDAAqD;AAErD,KAAK;AACL,YAAY;AAEZ;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CAYnC,QAWC,EACD,EAAE;IACF,OAAO,GAAG,EAAE;QACV,OAAO,IAAA,qBAAa,EASlB,QAAQ,CAAC,CAAC;IACd,CAAC,CAAC;AACJ,CAAC,CAAC;AArCW,QAAA,qBAAqB,yBAqChC;AAEF;;;GAGG;AACI,MAAM,aAAa,GAAG,CAY3B,QAWC,EACD,EAAE;IACF,IAAI,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1B,eAAe;IACf,MAAM;IAEN,uDAAuD;IACvD,cAAc;IACd,KAAK;IACL,MAAM,kBAAkB,GAAG,IAAI,kCAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG;QACV,eAAe;QACf,KAAK,EAAE;YACL,qBAAqB;YACrB,mBAAmB;YACnB,4BAA4B;YAC5B,KAAK;YACL,4CAA4C;YAC5C,mDAAmD;YACnD,2CAA2C;YAC3C,2CAA2C;YAC3C,o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AAC,8BAA8B,EAAE,CAAC;4BAC7D,MAAM,kBAAkB,CAAC,YAAY,CAAC,0BAA0B,CAC9D,kBAAkB,CAAC,8BAA8B,CAClD,CAAC;wBACJ,CAAC;6BAAM,CAAC;4BACN,MAAM,kBAAkB,CAAC,YAAY,CAAC,4BAA4B,EAAE,CAAC;wBACvE,CAAC;oBACH,CAAC;oBAED,OAAO,CAAC,kBAAkB,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;gBACH,YAAY;YACd,CAAC,CAAC,CAAC;QACL,CAAC;QACD;;;WAGG;QACH,IAAI,QAAQ;YACV,OAAO;gBACL,IAAI,MAAM;oBACR,OAAO,kBAAkB,CAAC,cAAc,CAAC;gBAC3C,CAAC;gBACD,IAAI,MAAM;oBACR,OAAO,kBAAkB,CAAC,cAAc,CAAC;gBAC3C,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AA9PW,QAAA,aAAa,iBA8PxB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Models } from '../../models';
|
|
2
|
+
/**
|
|
3
|
+
* Provider decorator
|
|
4
|
+
*/
|
|
5
|
+
export declare function TaonMiddleware<T = any>(options?: TaonMiddlewareOptions<T>): (constructor: Function) => void;
|
|
6
|
+
export declare class TaonMiddlewareOptions<T = any> extends Models.DecoratorAbstractOpt {
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaonMiddlewareOptions = void 0;
|
|
4
|
+
exports.TaonMiddleware = TaonMiddleware;
|
|
5
|
+
const class_helpers_1 = require("../../helpers/class-helpers");
|
|
6
|
+
const models_1 = require("../../models");
|
|
7
|
+
const symbols_1 = require("../../symbols");
|
|
8
|
+
/**
|
|
9
|
+
* Provider decorator
|
|
10
|
+
*/
|
|
11
|
+
function TaonMiddleware(options) {
|
|
12
|
+
return function (constructor) {
|
|
13
|
+
Reflect.defineMetadata(symbols_1.Symbols.metadata.options.provider, options, constructor);
|
|
14
|
+
Reflect.defineMetadata(symbols_1.Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
15
|
+
class_helpers_1.ClassHelpers.setName(constructor, options?.className || constructor.name);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
class TaonMiddlewareOptions extends models_1.Models.DecoratorAbstractOpt {
|
|
19
|
+
}
|
|
20
|
+
exports.TaonMiddlewareOptions = TaonMiddlewareOptions;
|
|
21
|
+
//# sourceMappingURL=middleware-decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-decorator.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAOA,wCAcC;AArBD,+DAA2D;AAC3D,yCAAsC;AACtC,2CAAwC;AAExC;;GAEG;AACH,SAAgB,cAAc,CAAU,OAAkC;IACxE,OAAO,UAAU,WAAqB;QACpC,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EACjC,OAAO,EACP,WAAW,CACZ,CAAC;QACF,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,SAAS,EAC1B,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,EACtC,WAAW,CACZ,CAAC;QACF,4BAAY,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC;AAED,MAAa,qBAEX,SAAQ,eAAM,CAAC,oBAAoB;CAEpC;AAJD,sDAIC"}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TaonProviderOptions = void 0;
|
|
4
4
|
exports.TaonProvider = TaonProvider;
|
|
5
5
|
const class_helpers_1 = require("../../helpers/class-helpers");
|
|
6
|
-
const symbols_1 = require("../../symbols");
|
|
7
6
|
const models_1 = require("../../models");
|
|
7
|
+
const symbols_1 = require("../../symbols");
|
|
8
8
|
/**
|
|
9
9
|
* Provider decorator
|
|
10
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-decorator.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAOA,oCAcC;AArBD,+DAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"provider-decorator.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAOA,oCAcC;AArBD,+DAA2D;AAC3D,yCAAsC;AACtC,2CAAwC;AAExC;;GAEG;AACH,SAAgB,YAAY,CAAU,OAAgC;IACpE,OAAO,UAAU,WAAqB;QACpC,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EACjC,OAAO,EACP,WAAW,CACZ,CAAC;QACF,OAAO,CAAC,cAAc,CACpB,iBAAO,CAAC,QAAQ,CAAC,SAAS,EAC1B,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,EACtC,WAAW,CACZ,CAAC;QACF,4BAAY,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC;AAED,MAAa,mBAEX,SAAQ,eAAM,CAAC,oBAAoB;CAEpC;AAJD,kDAIC"}
|
|
@@ -5,6 +5,7 @@ import type { Application } from 'express';
|
|
|
5
5
|
import type { Repository } from 'taon-typeorm';
|
|
6
6
|
import { DataSource } from 'taon-typeorm';
|
|
7
7
|
import type { BaseInjector } from './base-classes/base-injector';
|
|
8
|
+
export type { TaonMiddlewareInterceptOptions } from './base-classes/base-middleware';
|
|
8
9
|
import { ContextDbMigrations } from './context-db-migrations';
|
|
9
10
|
import { Models } from './models';
|
|
10
11
|
export declare class EndpointContext {
|
|
@@ -55,7 +56,7 @@ export declare class EndpointContext {
|
|
|
55
56
|
/**
|
|
56
57
|
* available after init()
|
|
57
58
|
*/
|
|
58
|
-
config: Models.ContextOptions<any, any, any, any, any, any, any>;
|
|
59
|
+
config: Models.ContextOptions<any, any, any, any, any, any, any, any>;
|
|
59
60
|
get logHttp(): boolean;
|
|
60
61
|
get logRealtime(): boolean;
|
|
61
62
|
get logFramework(): boolean;
|
|
@@ -65,7 +66,7 @@ export declare class EndpointContext {
|
|
|
65
66
|
* Inside docker there is not need for https secure server
|
|
66
67
|
*/
|
|
67
68
|
private isRunningInsideDocker;
|
|
68
|
-
constructor(originalConfig: Models.ContextOptions<any, any, any, any, any, any, any>, configFn: (env: any) => Models.ContextOptions<any, any, any, any, any, any, any>);
|
|
69
|
+
constructor(originalConfig: Models.ContextOptions<any, any, any, any, any, any, any, any>, configFn: (env: any) => Models.ContextOptions<any, any, any, any, any, any, any, any>);
|
|
69
70
|
init(options?: {
|
|
70
71
|
initFromRecrusiveContextResovle?: boolean;
|
|
71
72
|
overrideHost?: string | null;
|
|
@@ -99,13 +100,12 @@ export declare class EndpointContext {
|
|
|
99
100
|
isCLassType(classType: Models.ClassType, classFn: Function): boolean;
|
|
100
101
|
/**
|
|
101
102
|
* Only for injectable types
|
|
102
|
-
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER
|
|
103
|
+
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
|
|
103
104
|
*/
|
|
104
105
|
getClassFunByClassName(className: string): Function;
|
|
105
106
|
getClassFunByClass(classFunction: Function): Function;
|
|
106
107
|
getClassFunByArr(classType: Models.ClassType): Function[];
|
|
107
108
|
private createInstances;
|
|
108
|
-
reinitControllers(): Promise<void>;
|
|
109
109
|
initClasses(): Promise<void>;
|
|
110
110
|
isActiveOn(classInstance: object): boolean;
|
|
111
111
|
get frontendHostUri(): URL;
|
|
@@ -158,7 +158,8 @@ export declare class EndpointContext {
|
|
|
158
158
|
initControllers(): Promise<void>;
|
|
159
159
|
writeActiveRoutes(): void;
|
|
160
160
|
get middlewares(): Models.MiddlewareType[];
|
|
161
|
-
private
|
|
161
|
+
private initFrontnedMiddlewares;
|
|
162
|
+
private initBackendMiddlewares;
|
|
162
163
|
private initServer;
|
|
163
164
|
/**
|
|
164
165
|
* client can be browser or nodejs (when remote host)
|
package/lib/endpoint-context.js
CHANGED
|
@@ -97,6 +97,7 @@ class EndpointContext {
|
|
|
97
97
|
injectableTypesfromContexts = [
|
|
98
98
|
models_1.Models.ClassType.CONTROLLER,
|
|
99
99
|
models_1.Models.ClassType.PROVIDER,
|
|
100
|
+
models_1.Models.ClassType.MIDDLEWARE,
|
|
100
101
|
models_1.Models.ClassType.REPOSITORY,
|
|
101
102
|
models_1.Models.ClassType.SUBSCRIBER,
|
|
102
103
|
models_1.Models.ClassType.MIGRATION,
|
|
@@ -336,6 +337,10 @@ class EndpointContext {
|
|
|
336
337
|
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.PROVIDER)),
|
|
337
338
|
...this.config.providers,
|
|
338
339
|
};
|
|
340
|
+
this.config.middlewares = {
|
|
341
|
+
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.MIDDLEWARE)),
|
|
342
|
+
...this.config.middlewares,
|
|
343
|
+
};
|
|
339
344
|
this.config.subscribers = {
|
|
340
345
|
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.SUBSCRIBER)),
|
|
341
346
|
...this.config.subscribers,
|
|
@@ -370,6 +375,12 @@ class EndpointContext {
|
|
|
370
375
|
ctx: this,
|
|
371
376
|
classType: models_1.Models.ClassType.PROVIDER,
|
|
372
377
|
});
|
|
378
|
+
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
379
|
+
classesInput: this.config.middlewares,
|
|
380
|
+
config: this.config,
|
|
381
|
+
ctx: this,
|
|
382
|
+
classType: models_1.Models.ClassType.MIDDLEWARE,
|
|
383
|
+
});
|
|
373
384
|
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
374
385
|
classesInput: this.config.subscribers,
|
|
375
386
|
config: this.config,
|
|
@@ -397,7 +408,7 @@ class EndpointContext {
|
|
|
397
408
|
if (this.mode === 'backend-frontend(tcp+udp)' && !this.config.abstract) {
|
|
398
409
|
//#region @backend
|
|
399
410
|
this.expressApp = express();
|
|
400
|
-
this.
|
|
411
|
+
await this.initBackendMiddlewares();
|
|
401
412
|
const shouldStartHttpsSecureServer = this.isHttpServer && !this.isRunningInsideDocker;
|
|
402
413
|
this.logFramework &&
|
|
403
414
|
lib_10.Helpers.info(`
|
|
@@ -415,6 +426,7 @@ class EndpointContext {
|
|
|
415
426
|
this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
|
|
416
427
|
});
|
|
417
428
|
//#endregion
|
|
429
|
+
await this.initFrontnedMiddlewares();
|
|
418
430
|
}
|
|
419
431
|
//#endregion
|
|
420
432
|
//#region prepare realtime
|
|
@@ -526,7 +538,7 @@ class EndpointContext {
|
|
|
526
538
|
//#region @backend
|
|
527
539
|
if (lib_8.UtilsOs.isElectron) {
|
|
528
540
|
dbLocationInOs = (0, lib_9.crossPlatformPath)([
|
|
529
|
-
|
|
541
|
+
lib_8.UtilsOs.getRealHomeDir(),
|
|
530
542
|
`.taon/databases-for-electron-apps/${this.appId || lib_10._.snakeCase(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
|
|
531
543
|
]);
|
|
532
544
|
if (!lib_10.Helpers.exists(lib_11.path.dirname(dbLocationInOs))) {
|
|
@@ -893,6 +905,8 @@ class EndpointContext {
|
|
|
893
905
|
return this.config.entities;
|
|
894
906
|
case models_1.Models.ClassType.PROVIDER:
|
|
895
907
|
return this.config.providers;
|
|
908
|
+
case models_1.Models.ClassType.MIDDLEWARE:
|
|
909
|
+
return this.config.middlewares;
|
|
896
910
|
case models_1.Models.ClassType.REPOSITORY:
|
|
897
911
|
return this.config.repositories;
|
|
898
912
|
case models_1.Models.ClassType.SUBSCRIBER:
|
|
@@ -906,7 +920,7 @@ class EndpointContext {
|
|
|
906
920
|
}
|
|
907
921
|
/**
|
|
908
922
|
* Only for injectable types
|
|
909
|
-
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER
|
|
923
|
+
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
|
|
910
924
|
*/
|
|
911
925
|
getClassFunByClassName(className) {
|
|
912
926
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
@@ -946,25 +960,7 @@ class EndpointContext {
|
|
|
946
960
|
}
|
|
947
961
|
}
|
|
948
962
|
//#endregion
|
|
949
|
-
//#region methods & getters /
|
|
950
|
-
async reinitControllers() {
|
|
951
|
-
if (this.remoteHost || Object.keys(this.config.migrations).length > 0) {
|
|
952
|
-
return;
|
|
953
|
-
}
|
|
954
|
-
// Helpers.taskStarted(
|
|
955
|
-
// `[taon] REINITING CONTROLLERS ${this.contextName} STARTED`,
|
|
956
|
-
// );
|
|
957
|
-
const controllers = this.getClassesInstancesArrBy(models_1.Models.ClassType.CONTROLLER);
|
|
958
|
-
// console.log('CONTROLLERS TO REINIT', controllers);
|
|
959
|
-
for (const ctrl of controllers) {
|
|
960
|
-
if (lib_10._.isFunction(ctrl.initExampleDbData)) {
|
|
961
|
-
await ctrl.initExampleDbData();
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
// Helpers.taskDone(
|
|
965
|
-
// `[taon] REINITING CONTROLLERS ${this.contextName} DONE`,
|
|
966
|
-
// );
|
|
967
|
-
}
|
|
963
|
+
//#region methods & getters / init classes
|
|
968
964
|
async initClasses() {
|
|
969
965
|
if (this.remoteHost) {
|
|
970
966
|
return;
|
|
@@ -976,6 +972,7 @@ class EndpointContext {
|
|
|
976
972
|
}
|
|
977
973
|
//#endregion
|
|
978
974
|
for (const classTypeName of [
|
|
975
|
+
models_1.Models.ClassType.MIDDLEWARE,
|
|
979
976
|
models_1.Models.ClassType.PROVIDER,
|
|
980
977
|
models_1.Models.ClassType.REPOSITORY,
|
|
981
978
|
models_1.Models.ClassType.CONTROLLER,
|
|
@@ -991,6 +988,7 @@ class EndpointContext {
|
|
|
991
988
|
//#endregion
|
|
992
989
|
}
|
|
993
990
|
for (const classTypeName of [
|
|
991
|
+
models_1.Models.ClassType.MIDDLEWARE,
|
|
994
992
|
models_1.Models.ClassType.PROVIDER,
|
|
995
993
|
models_1.Models.ClassType.REPOSITORY,
|
|
996
994
|
models_1.Models.ClassType.CONTROLLER,
|
|
@@ -1191,7 +1189,7 @@ class EndpointContext {
|
|
|
1191
1189
|
//#region methods & getters / init connection
|
|
1192
1190
|
async initDatabaseConnection() {
|
|
1193
1191
|
//#region @websqlFunc
|
|
1194
|
-
if (this.remoteHost) {
|
|
1192
|
+
if (this.remoteHost || !this.databaseConfig) {
|
|
1195
1193
|
return;
|
|
1196
1194
|
}
|
|
1197
1195
|
const entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY).map(entityFn => {
|
|
@@ -1434,15 +1432,67 @@ class EndpointContext {
|
|
|
1434
1432
|
}
|
|
1435
1433
|
//#endregion
|
|
1436
1434
|
//#region methods & getters / init middlewares
|
|
1437
|
-
|
|
1435
|
+
async initFrontnedMiddlewares() {
|
|
1436
|
+
const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE);
|
|
1437
|
+
for (const middleware of middlewares) {
|
|
1438
|
+
const middlewareInstance = middleware;
|
|
1439
|
+
if (lib_10._.isFunction(middlewareInstance.intercept)) {
|
|
1440
|
+
((instance, contextName, apiPart, uriPathnameOrNothingIfRoot) => {
|
|
1441
|
+
const interceptorName = `${contextName}-${class_helpers_1.ClassHelpers.getName(instance)}`;
|
|
1442
|
+
lib_3.Resource.request.interceptors.set(interceptorName, async (req) => {
|
|
1443
|
+
console.log('request', req);
|
|
1444
|
+
const url = new url_1.URL(req.url);
|
|
1445
|
+
if (url.pathname.startsWith(`${uriPathnameOrNothingIfRoot}/${apiPart}/${contextName}/`)) {
|
|
1446
|
+
await instance.intercept({
|
|
1447
|
+
client: {
|
|
1448
|
+
req,
|
|
1449
|
+
},
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
else {
|
|
1453
|
+
// console.log('not fit frontend', url.href);
|
|
1454
|
+
}
|
|
1455
|
+
return req;
|
|
1456
|
+
});
|
|
1457
|
+
})(middlewareInstance, this.contextName, constants_1.apiPrefix, this.uriPathnameOrNothingIfRoot);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
async initBackendMiddlewares() {
|
|
1438
1462
|
//#region @backend
|
|
1439
1463
|
const app = this.expressApp;
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1464
|
+
const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE);
|
|
1465
|
+
for (const middleware of middlewares) {
|
|
1466
|
+
const middlewareInstance = middleware;
|
|
1467
|
+
if (lib_10._.isFunction(middlewareInstance.intercept)) {
|
|
1468
|
+
((instance, contextName, apiPart, uriPathnameOrNothingIfRoot) => {
|
|
1469
|
+
const asyncHandler = fn => (req, res, next) => {
|
|
1470
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
1471
|
+
};
|
|
1472
|
+
const middlewareFn = asyncHandler(async (req, res, next) => {
|
|
1473
|
+
if (req.originalUrl.startsWith(`${uriPathnameOrNothingIfRoot}/${apiPart}/${contextName}/`)) {
|
|
1474
|
+
await instance.intercept({
|
|
1475
|
+
server: {
|
|
1476
|
+
req,
|
|
1477
|
+
res,
|
|
1478
|
+
},
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
else {
|
|
1482
|
+
// console.log('not fit backend', url.href);
|
|
1483
|
+
}
|
|
1484
|
+
next();
|
|
1485
|
+
});
|
|
1486
|
+
app.use(middlewareFn);
|
|
1487
|
+
})(middlewareInstance, this.contextName, constants_1.apiPrefix, this.uriPathnameOrNothingIfRoot);
|
|
1488
|
+
}
|
|
1445
1489
|
}
|
|
1490
|
+
// if (this.middlewares) {
|
|
1491
|
+
// this.middlewares.forEach(m => {
|
|
1492
|
+
// const [fun, args] = m;
|
|
1493
|
+
// app.use(fun.apply(null, args));
|
|
1494
|
+
// });
|
|
1495
|
+
// }
|
|
1446
1496
|
this.expressApp.get('/helloworld', (req, res) => {
|
|
1447
1497
|
res.send(`Hello, world from context ${this.contextName}`);
|
|
1448
1498
|
});
|