taon 19.0.51 → 19.0.53
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/README.md +160 -160
- package/bin/start.js +279 -279
- package/bin/taon +6 -6
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +5 -5
- package/browser/README.md +24 -24
- package/browser/fesm2022/taon.mjs +188 -95
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-angular-service.d.ts +3 -6
- 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 +7 -6
- 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-angular-service.d.ts +3 -6
- package/lib/base-classes/base-angular-service.js +12 -16
- package/lib/base-classes/base-angular-service.js.map +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 +7 -6
- package/lib/endpoint-context.js +87 -32
- package/lib/endpoint-context.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/realtime/realtime-client.js +2 -1
- package/lib/realtime/realtime-client.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/README.md +24 -24
- package/websql/fesm2022/taon.mjs +192 -97
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-angular-service.d.ts +3 -6
- 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 +7 -6
- package/websql/lib/index.d.ts +8 -2
- package/websql/lib/models.d.ts +65 -5
- package/websql/package.json +1 -1
- package/env.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.__.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.dev.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.localhost.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.prod.d.ts +0 -3
- package/environments/angular-node-app/env.angular-node-app.stage.d.ts +0 -3
- package/environments/docs-webapp/env.docs-webapp.__.d.ts +0 -3
- package/environments/electron-app/env.electron-app.__.d.ts +0 -3
- package/environments/electron-app/env.electron-app.prod.d.ts +0 -3
- package/environments/mobile-app/env.mobile-app.__.d.ts +0 -3
- package/environments/mobile-app/env.mobile-app.prod.d.ts +0 -3
- package/environments/npm-lib-and-cli-tool/env.npm-lib-and-cli-tool.__.d.ts +0 -3
- package/environments/npm-lib-and-cli-tool/env.npm-lib-and-cli-tool.prod.d.ts +0 -3
- package/environments/vscode-plugin/env.vscode-plugin.__.d.ts +0 -6
- package/environments/vscode-plugin/env.vscode-plugin.prod.d.ts +0 -4
- 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/taon-admin-mode-configuration.component.d.ts +0 -43
- 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/tmp-environment.json +0 -32
|
@@ -5,6 +5,7 @@ import * as controller from './base-controller';
|
|
|
5
5
|
import * as crudController from './base-crud-controller';
|
|
6
6
|
import * as customRepository from './base-custom-repository';
|
|
7
7
|
import * as entity from './base-entity';
|
|
8
|
+
import * as baseMiddleware from './base-middleware';
|
|
8
9
|
import * as baseMigration from './base-migration';
|
|
9
10
|
import * as provider from './base-provider';
|
|
10
11
|
import * as repository from './base-repository';
|
|
@@ -21,6 +22,7 @@ export declare namespace Base {
|
|
|
21
22
|
export import CustomRepository = customRepository.BaseCustomRepository;
|
|
22
23
|
export import SubscriberForEntity = baseSubscriberEntity.BaseSubscriberForEntity;
|
|
23
24
|
export import Migration = baseMigration.BaseMigration;
|
|
25
|
+
export import Middleware = baseMiddleware.BaseMiddleware;
|
|
24
26
|
export import AngularService = baseService.BaseAngularsService;
|
|
25
27
|
const Context: {
|
|
26
28
|
types: {
|
|
@@ -29,6 +31,7 @@ export declare namespace Base {
|
|
|
29
31
|
readonly providers: any;
|
|
30
32
|
readonly subscribers: any;
|
|
31
33
|
readonly migrations: any;
|
|
34
|
+
readonly middlewares: any;
|
|
32
35
|
};
|
|
33
36
|
readonly contexts: any;
|
|
34
37
|
readonly contextName: string;
|
package/lib/base-classes/base.js
CHANGED
|
@@ -9,6 +9,7 @@ const controller = require("./base-controller");
|
|
|
9
9
|
const crudController = require("./base-crud-controller");
|
|
10
10
|
const customRepository = require("./base-custom-repository");
|
|
11
11
|
const entity = require("./base-entity");
|
|
12
|
+
const baseMiddleware = require("./base-middleware");
|
|
12
13
|
const baseMigration = require("./base-migration");
|
|
13
14
|
const provider = require("./base-provider");
|
|
14
15
|
const repository = require("./base-repository");
|
|
@@ -25,6 +26,7 @@ var Base;
|
|
|
25
26
|
Base.CustomRepository = customRepository.BaseCustomRepository;
|
|
26
27
|
Base.SubscriberForEntity = baseSubscriberEntity.BaseSubscriberForEntity;
|
|
27
28
|
Base.Migration = baseMigration.BaseMigration;
|
|
29
|
+
Base.Middleware = baseMiddleware.BaseMiddleware;
|
|
28
30
|
Base.AngularService = baseService.BaseAngularsService;
|
|
29
31
|
Base.Context = baseContext.BaseContext;
|
|
30
32
|
})(Base || (exports.Base = Base = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,sDAAsD;AACtD,0CAA0C;AAC1C,8CAA8C;AAC9C,gDAAgD;AAChD,yDAAyD;AACzD,6DAA6D;AAC7D,wCAAwC;AACxC,kDAAkD;AAClD,4CAA4C;AAC5C,gDAAgD;AAChD,qEAAqE;AACrE,IAAiB,IAAI,
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,sDAAsD;AACtD,0CAA0C;AAC1C,8CAA8C;AAC9C,gDAAgD;AAChD,yDAAyD;AACzD,6DAA6D;AAC7D,wCAAwC;AACxC,oDAAoD;AACpD,kDAAkD;AAClD,4CAA4C;AAC5C,gDAAgD;AAChD,qEAAqE;AACrE,IAAiB,IAAI,CAepB;AAfD,WAAiB,IAAI;IACL,eAAU,GAAG,UAAU,CAAC,cAAc,CAAC;IACvC,mBAAc,GAAG,cAAc,CAAC,kBAAkB,CAAC;IACnD,WAAM,GAAG,MAAM,CAAC,UAAU,CAAC;IAC3B,mBAAc,GAAG,cAAc,CAAC,kBAAkB,CAAC;IAEnD,aAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC;IACjC,UAAK,GAAG,SAAS,CAAC,SAAS,CAAC;IAC5B,eAAU,GAAG,UAAU,CAAC,cAAc,CAAC;IACvC,qBAAgB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC;IACzD,wBAAmB,GAAG,oBAAoB,CAAC,uBAAuB,CAAC;IACnE,cAAS,GAAG,aAAa,CAAC,aAAa,CAAC;IACxC,eAAU,GAAG,cAAc,CAAC,cAAc,CAAC;IAC3C,mBAAc,GAAG,WAAW,CAAC,mBAAmB,CAAC;IAClD,YAAO,GAAG,WAAW,CAAC,WAAW,CAAC;AACjD,CAAC,EAfgB,IAAI,oBAAJ,IAAI,QAepB"}
|
|
@@ -21,6 +21,6 @@ exports.PROJECT_NPM_NAME = 'taon';
|
|
|
21
21
|
/**
|
|
22
22
|
* Autogenerated by current cli tool. Use *tnp release* to bump version.
|
|
23
23
|
*/
|
|
24
|
-
exports.CURRENT_PACKAGE_VERSION = '19.0.
|
|
24
|
+
exports.CURRENT_PACKAGE_VERSION = '19.0.53';
|
|
25
25
|
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
26
26
|
//# sourceMappingURL=build-info._auto-generated_.js.map
|
package/lib/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type TaonEntityKeysToOmit = 'ctrl' | 'clone' | '__endpoint_context__' | 'ctx' | 'inject' | '_' | 'relation' | 'relations' | 'inject' | 'injectRepo' | 'injectCustomRepository' | 'injectCustomRepo' | 'injectController' | 'injectCtrl' | '
|
|
1
|
+
export type TaonEntityKeysToOmit = 'ctrl' | 'clone' | '__endpoint_context__' | 'ctx' | 'inject' | '_' | 'relation' | 'relations' | 'inject' | 'injectRepo' | 'injectCustomRepository' | 'injectCustomRepo' | 'injectController' | 'injectCtrl' | 'injectProvider' | 'injectMiddleware';
|
|
2
2
|
export declare const TaonEntityKeysToOmitArr: TaonEntityKeysToOmit[];
|
|
3
3
|
import { InjectionToken } from '@angular/core';
|
|
4
4
|
import type { TaonContext } from './create-context';
|
package/lib/constants.js
CHANGED
|
@@ -16,9 +16,8 @@ exports.TaonEntityKeysToOmitArr = [
|
|
|
16
16
|
'injectCustomRepo',
|
|
17
17
|
'injectController',
|
|
18
18
|
'injectCtrl',
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'injectContextProvider',
|
|
19
|
+
'injectProvider',
|
|
20
|
+
'injectMiddleware',
|
|
22
21
|
];
|
|
23
22
|
let TAON_CONTEXT;
|
|
24
23
|
/* */
|
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAkBa,QAAA,uBAAuB,GAA2B;IAC7D,MAAM;IACN,OAAO;IACP,sBAAsB;IACtB,KAAK;IACL,QAAQ;IACR,GAAG;IACH,UAAU;IACV,WAAW;IACX,QAAQ;IACR,YAAY;IACZ,wBAAwB;IACxB,kBAAkB;IAClB,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,kBAAkB;CACnB,CAAC;AAMF,IAAI,YAAyC,CAAC;AAC9C,KAAK;AACL,KAAK;AAGL,IAAI,yBAAiD,CAAC;AASzC,QAAA,SAAS,GAAG,KAAK,CAAC"}
|
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,"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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;
|
|
@@ -64,8 +65,8 @@ export declare class EndpointContext {
|
|
|
64
65
|
/**
|
|
65
66
|
* Inside docker there is not need for https secure server
|
|
66
67
|
*/
|
|
67
|
-
|
|
68
|
-
constructor(originalConfig: Models.ContextOptions<any, any, any, any, any, any, any>, configFn: (env: any) => Models.ContextOptions<any, any, any, any, any, any, any>);
|
|
68
|
+
readonly isRunningInsideDocker: boolean;
|
|
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,10 @@ class EndpointContext {
|
|
|
397
408
|
if (this.mode === 'backend-frontend(tcp+udp)' && !this.config.abstract) {
|
|
398
409
|
//#region @backend
|
|
399
410
|
this.expressApp = express();
|
|
400
|
-
|
|
411
|
+
if (process.env.NODE_ENV === 'production') {
|
|
412
|
+
this.expressApp.set('trust proxy', 1);
|
|
413
|
+
}
|
|
414
|
+
await this.initBackendMiddlewares();
|
|
401
415
|
const shouldStartHttpsSecureServer = this.isHttpServer && !this.isRunningInsideDocker;
|
|
402
416
|
this.logFramework &&
|
|
403
417
|
lib_10.Helpers.info(`
|
|
@@ -415,6 +429,7 @@ class EndpointContext {
|
|
|
415
429
|
this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
|
|
416
430
|
});
|
|
417
431
|
//#endregion
|
|
432
|
+
await this.initFrontnedMiddlewares();
|
|
418
433
|
}
|
|
419
434
|
//#endregion
|
|
420
435
|
//#region prepare realtime
|
|
@@ -601,7 +616,7 @@ class EndpointContext {
|
|
|
601
616
|
lib_10.Helpers.log(`Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
|
|
602
617
|
lib_10.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
603
618
|
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
604
|
-
|
|
619
|
+
ExpressJS mode: ${this.expressApp.settings.env}
|
|
605
620
|
`);
|
|
606
621
|
resolve(void 0);
|
|
607
622
|
});
|
|
@@ -611,8 +626,8 @@ class EndpointContext {
|
|
|
611
626
|
this.serverTcpUdp.listen(Number(this.uriPort), () => {
|
|
612
627
|
lib_10.Helpers.log(`Express server (inside nodejs app) started on localhost:${this.uriPort}`);
|
|
613
628
|
lib_10.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
614
|
-
|
|
615
|
-
|
|
629
|
+
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
630
|
+
expressJS mode: ${this.expressApp.settings.env}
|
|
616
631
|
`);
|
|
617
632
|
resolve(void 0);
|
|
618
633
|
});
|
|
@@ -893,6 +908,8 @@ class EndpointContext {
|
|
|
893
908
|
return this.config.entities;
|
|
894
909
|
case models_1.Models.ClassType.PROVIDER:
|
|
895
910
|
return this.config.providers;
|
|
911
|
+
case models_1.Models.ClassType.MIDDLEWARE:
|
|
912
|
+
return this.config.middlewares;
|
|
896
913
|
case models_1.Models.ClassType.REPOSITORY:
|
|
897
914
|
return this.config.repositories;
|
|
898
915
|
case models_1.Models.ClassType.SUBSCRIBER:
|
|
@@ -906,7 +923,7 @@ class EndpointContext {
|
|
|
906
923
|
}
|
|
907
924
|
/**
|
|
908
925
|
* Only for injectable types
|
|
909
|
-
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER
|
|
926
|
+
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
|
|
910
927
|
*/
|
|
911
928
|
getClassFunByClassName(className) {
|
|
912
929
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
@@ -946,25 +963,7 @@ class EndpointContext {
|
|
|
946
963
|
}
|
|
947
964
|
}
|
|
948
965
|
//#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
|
-
}
|
|
966
|
+
//#region methods & getters / init classes
|
|
968
967
|
async initClasses() {
|
|
969
968
|
if (this.remoteHost) {
|
|
970
969
|
return;
|
|
@@ -976,6 +975,7 @@ class EndpointContext {
|
|
|
976
975
|
}
|
|
977
976
|
//#endregion
|
|
978
977
|
for (const classTypeName of [
|
|
978
|
+
models_1.Models.ClassType.MIDDLEWARE,
|
|
979
979
|
models_1.Models.ClassType.PROVIDER,
|
|
980
980
|
models_1.Models.ClassType.REPOSITORY,
|
|
981
981
|
models_1.Models.ClassType.CONTROLLER,
|
|
@@ -991,6 +991,7 @@ class EndpointContext {
|
|
|
991
991
|
//#endregion
|
|
992
992
|
}
|
|
993
993
|
for (const classTypeName of [
|
|
994
|
+
models_1.Models.ClassType.MIDDLEWARE,
|
|
994
995
|
models_1.Models.ClassType.PROVIDER,
|
|
995
996
|
models_1.Models.ClassType.REPOSITORY,
|
|
996
997
|
models_1.Models.ClassType.CONTROLLER,
|
|
@@ -1191,7 +1192,7 @@ class EndpointContext {
|
|
|
1191
1192
|
//#region methods & getters / init connection
|
|
1192
1193
|
async initDatabaseConnection() {
|
|
1193
1194
|
//#region @websqlFunc
|
|
1194
|
-
if (this.remoteHost) {
|
|
1195
|
+
if (this.remoteHost || !this.databaseConfig) {
|
|
1195
1196
|
return;
|
|
1196
1197
|
}
|
|
1197
1198
|
const entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY).map(entityFn => {
|
|
@@ -1266,7 +1267,9 @@ class EndpointContext {
|
|
|
1266
1267
|
[taon][typeorm] db prepration done.. db initialize=${this.connection?.isInitialized}
|
|
1267
1268
|
|
|
1268
1269
|
|
|
1269
|
-
`,
|
|
1270
|
+
`,
|
|
1271
|
+
// dataSourceDbConfig,
|
|
1272
|
+
{ 'this.connection': !!this.connection });
|
|
1270
1273
|
console.log(`Database file location: ${this.connection.options.database}`);
|
|
1271
1274
|
}
|
|
1272
1275
|
// const entityMetadata = getMetadataArgsStorage();
|
|
@@ -1434,15 +1437,67 @@ class EndpointContext {
|
|
|
1434
1437
|
}
|
|
1435
1438
|
//#endregion
|
|
1436
1439
|
//#region methods & getters / init middlewares
|
|
1437
|
-
|
|
1440
|
+
async initFrontnedMiddlewares() {
|
|
1441
|
+
const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE);
|
|
1442
|
+
for (const middleware of middlewares) {
|
|
1443
|
+
const middlewareInstance = middleware;
|
|
1444
|
+
if (lib_10._.isFunction(middlewareInstance.intercept)) {
|
|
1445
|
+
((instance, contextName, apiPart, uriPathnameOrNothingIfRoot) => {
|
|
1446
|
+
const interceptorName = `${contextName}-${class_helpers_1.ClassHelpers.getName(instance)}`;
|
|
1447
|
+
lib_3.Resource.request.interceptors.set(interceptorName, async (req) => {
|
|
1448
|
+
console.log('request', req);
|
|
1449
|
+
const url = new url_1.URL(req.url);
|
|
1450
|
+
if (url.pathname.startsWith(`${uriPathnameOrNothingIfRoot}/${apiPart}/${contextName}/`)) {
|
|
1451
|
+
await instance.intercept({
|
|
1452
|
+
client: {
|
|
1453
|
+
req,
|
|
1454
|
+
},
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
else {
|
|
1458
|
+
// console.log('not fit frontend', url.href);
|
|
1459
|
+
}
|
|
1460
|
+
return req;
|
|
1461
|
+
});
|
|
1462
|
+
})(middlewareInstance, this.contextName, constants_1.apiPrefix, this.uriPathnameOrNothingIfRoot);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
async initBackendMiddlewares() {
|
|
1438
1467
|
//#region @backend
|
|
1439
1468
|
const app = this.expressApp;
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1469
|
+
const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE);
|
|
1470
|
+
for (const middleware of middlewares) {
|
|
1471
|
+
const middlewareInstance = middleware;
|
|
1472
|
+
if (lib_10._.isFunction(middlewareInstance.intercept)) {
|
|
1473
|
+
((instance, contextName, apiPart, uriPathnameOrNothingIfRoot) => {
|
|
1474
|
+
const asyncHandler = fn => (req, res, next) => {
|
|
1475
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
1476
|
+
};
|
|
1477
|
+
const middlewareFn = asyncHandler(async (req, res, next) => {
|
|
1478
|
+
if (req.originalUrl.startsWith(`${uriPathnameOrNothingIfRoot}/${apiPart}/${contextName}/`)) {
|
|
1479
|
+
await instance.intercept({
|
|
1480
|
+
server: {
|
|
1481
|
+
req,
|
|
1482
|
+
res,
|
|
1483
|
+
},
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
else {
|
|
1487
|
+
// console.log('not fit backend', url.href);
|
|
1488
|
+
}
|
|
1489
|
+
next();
|
|
1490
|
+
});
|
|
1491
|
+
app.use(middlewareFn);
|
|
1492
|
+
})(middlewareInstance, this.contextName, constants_1.apiPrefix, this.uriPathnameOrNothingIfRoot);
|
|
1493
|
+
}
|
|
1445
1494
|
}
|
|
1495
|
+
// if (this.middlewares) {
|
|
1496
|
+
// this.middlewares.forEach(m => {
|
|
1497
|
+
// const [fun, args] = m;
|
|
1498
|
+
// app.use(fun.apply(null, args));
|
|
1499
|
+
// });
|
|
1500
|
+
// }
|
|
1446
1501
|
this.expressApp.get('/helloworld', (req, res) => {
|
|
1447
1502
|
res.send(`Hello, world from context ${this.contextName}`);
|
|
1448
1503
|
});
|