taon 19.0.61 → 19.0.63
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 +281 -281
- 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 +177 -76
- package/browser/fesm2022/taon.mjs.map +1 -1
- package/browser/lib/base-classes/base-context.d.ts +6 -0
- package/browser/lib/base-classes/base-controller.d.ts +3 -3
- package/browser/lib/base-classes/base.d.ts +6 -0
- package/browser/lib/create-context.d.ts +12 -4
- package/browser/lib/endpoint-context-storage.d.ts +11 -0
- package/browser/lib/endpoint-context.d.ts +28 -8
- package/browser/lib/index.d.ts +19 -0
- package/browser/lib/models.d.ts +7 -8
- package/browser/package.json +1 -1
- package/lib/base-classes/base-context.d.ts +6 -0
- package/lib/base-classes/base-controller.d.ts +3 -3
- package/lib/base-classes/base-controller.js +2 -2
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/base-classes/base.d.ts +6 -0
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/context-db-migrations.js +5 -5
- package/lib/context-db-migrations.js.map +1 -1
- package/lib/create-context.d.ts +12 -4
- package/lib/create-context.js +35 -5
- package/lib/create-context.js.map +1 -1
- package/lib/endpoint-context-storage.d.ts +10 -0
- package/lib/endpoint-context-storage.js +34 -0
- package/lib/endpoint-context-storage.js.map +1 -0
- package/lib/endpoint-context.d.ts +28 -8
- package/lib/endpoint-context.js +96 -55
- package/lib/endpoint-context.js.map +1 -1
- package/lib/index.d.ts +19 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +7 -8
- package/lib/models.js.map +1 -1
- package/lib/realtime/realtime-client.js +12 -10
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/realtime/realtime-core.js +6 -3
- package/lib/realtime/realtime-core.js.map +1 -1
- package/lib/realtime/realtime-server.js +6 -5
- package/lib/realtime/realtime-server.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 +184 -83
- package/websql/fesm2022/taon.mjs.map +1 -1
- package/websql/lib/base-classes/base-context.d.ts +6 -0
- package/websql/lib/base-classes/base-controller.d.ts +3 -3
- package/websql/lib/base-classes/base.d.ts +6 -0
- package/websql/lib/create-context.d.ts +12 -4
- package/websql/lib/endpoint-context-storage.d.ts +11 -0
- package/websql/lib/endpoint-context.d.ts +28 -8
- package/websql/lib/index.d.ts +19 -0
- package/websql/lib/models.d.ts +7 -8
- package/websql/package.json +1 -1
- package/lib/decorators/classes/controller-config.d.ts +0 -0
- package/lib/decorators/classes/controller-config.js +0 -5
- package/lib/decorators/classes/controller-config.js.map +0 -1
- package/lib/decorators/classes/controller-options.d.ts +0 -0
- package/lib/decorators/classes/controller-options.js +0 -5
- package/lib/decorators/classes/controller-options.js.map +0 -1
- package/lib/env.d.ts +0 -2
- package/lib/env.js +0 -7
- package/lib/env.js.map +0 -1
- package/lib/storage.d.ts +0 -1
- package/lib/storage.js +0 -6
- package/lib/storage.js.map +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextsEndpointStorage = void 0;
|
|
4
|
+
class ContextsEndpointStorage {
|
|
5
|
+
taonEndpointContexts = new Map();
|
|
6
|
+
//#region singleton
|
|
7
|
+
static instance;
|
|
8
|
+
constructor() {
|
|
9
|
+
// Private constructor to prevent direct instantiation
|
|
10
|
+
}
|
|
11
|
+
static get Instance() {
|
|
12
|
+
if (!ContextsEndpointStorage.instance) {
|
|
13
|
+
ContextsEndpointStorage.instance = new ContextsEndpointStorage();
|
|
14
|
+
}
|
|
15
|
+
return ContextsEndpointStorage.instance;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
set(context) {
|
|
19
|
+
if (!this.taonEndpointContexts.has(context.contextName)) {
|
|
20
|
+
this.taonEndpointContexts.set(context.contextName, context);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
get arr() {
|
|
24
|
+
return Array.from(this.taonEndpointContexts.values()).filter(f => f.contextType === 'normal');
|
|
25
|
+
}
|
|
26
|
+
getBy(context) {
|
|
27
|
+
if (typeof context === 'string') {
|
|
28
|
+
return this.taonEndpointContexts.get(context);
|
|
29
|
+
}
|
|
30
|
+
return this.taonEndpointContexts.get(context.contextName);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ContextsEndpointStorage = ContextsEndpointStorage;
|
|
34
|
+
//# sourceMappingURL=endpoint-context-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-context-storage.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAEA,MAAa,uBAAuB;IAC1B,oBAAoB,GAAG,IAAI,GAAG,EAA2B,CAAC;IAElE,mBAAmB;IACX,MAAM,CAAC,QAAQ,CAA0B;IAEjD;QACE,sDAAsD;IACxD,CAAC;IAEM,MAAM,KAAK,QAAQ;QACxB,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,CAAC;YACtC,uBAAuB,CAAC,QAAQ,GAAG,IAAI,uBAAuB,EAAE,CAAC;QACnE,CAAC;QACD,OAAO,uBAAuB,CAAC,QAAQ,CAAC;IAC1C,CAAC;IACD,YAAY;IAEZ,GAAG,CAAC,OAAwB;QAC1B,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,IAAI,GAAG;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAC1D,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,QAAQ,CAChC,CAAC;IACJ,CAAC;IAED,KAAK,CACH,OAA0C;QAE1C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAQ,CAAC;QACvD,CAAC;QACD,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAQ,CAAC;IACnE,CAAC;CACF;AAtCD,0DAsCC"}
|
|
@@ -6,10 +6,18 @@ import type { Repository } from 'taon-typeorm';
|
|
|
6
6
|
import { DataSource } from 'taon-typeorm';
|
|
7
7
|
import type { BaseInjector } from './base-classes/base-injector';
|
|
8
8
|
import { ContextDbMigrations } from './context-db-migrations';
|
|
9
|
+
import type { ContextsEndpointStorage } from './endpoint-context-storage';
|
|
9
10
|
import { Models } from './models';
|
|
10
11
|
export declare class EndpointContext {
|
|
11
12
|
private originalConfig;
|
|
12
13
|
private configFn;
|
|
14
|
+
/**
|
|
15
|
+
* (@default: false)
|
|
16
|
+
* If TRUE context is NOT going to create db/express server/http endpoints
|
|
17
|
+
* PURPOSE OF THIS PROPERTY
|
|
18
|
+
* -> ONLY remote access from backend or frontend to specific backend
|
|
19
|
+
*/
|
|
20
|
+
private readonly cloneOptions;
|
|
13
21
|
/**
|
|
14
22
|
* JUST FOR TESTING PURPOSES
|
|
15
23
|
*/
|
|
@@ -36,6 +44,7 @@ export declare class EndpointContext {
|
|
|
36
44
|
method: Models.Http.Rest.HttpMethod;
|
|
37
45
|
}[];
|
|
38
46
|
repos: Map<string, Repository<any>>;
|
|
47
|
+
get sourceContext(): EndpointContext | undefined;
|
|
39
48
|
readonly skipWritingServerRoutes: boolean;
|
|
40
49
|
private injectableTypesfromContexts;
|
|
41
50
|
private allTypesfromContexts;
|
|
@@ -65,11 +74,16 @@ export declare class EndpointContext {
|
|
|
65
74
|
* Inside docker there is not need for https secure server
|
|
66
75
|
*/
|
|
67
76
|
readonly isRunningInsideDocker: boolean;
|
|
68
|
-
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
|
|
77
|
+
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>,
|
|
78
|
+
/**
|
|
79
|
+
* (@default: false)
|
|
80
|
+
* If TRUE context is NOT going to create db/express server/http endpoints
|
|
81
|
+
* PURPOSE OF THIS PROPERTY
|
|
82
|
+
* -> ONLY remote access from backend or frontend to specific backend
|
|
83
|
+
*/
|
|
84
|
+
cloneOptions: Models.TaonCtxCloneParams);
|
|
69
85
|
init(options?: {
|
|
70
86
|
initFromRecrusiveContextResovle?: boolean;
|
|
71
|
-
overrideHost?: string | null;
|
|
72
|
-
overrideRemoteHost?: string | null;
|
|
73
87
|
onlyMigrationRun?: boolean;
|
|
74
88
|
onlyMigrationRevertToTimestamp?: number;
|
|
75
89
|
}): Promise<void>;
|
|
@@ -108,7 +122,7 @@ export declare class EndpointContext {
|
|
|
108
122
|
initClasses(): Promise<void>;
|
|
109
123
|
isActiveOn(classInstance: object): boolean;
|
|
110
124
|
get frontendHostUri(): URL;
|
|
111
|
-
get uri(): URL;
|
|
125
|
+
get uri(): URL | undefined;
|
|
112
126
|
get uriProtocol(): string | undefined;
|
|
113
127
|
/**
|
|
114
128
|
* Examples
|
|
@@ -136,10 +150,19 @@ export declare class EndpointContext {
|
|
|
136
150
|
*/
|
|
137
151
|
get port(): Number | undefined;
|
|
138
152
|
get isHttpServer(): boolean;
|
|
153
|
+
get isRemoteHost(): boolean;
|
|
139
154
|
/**
|
|
140
155
|
* ipc/udp needs this
|
|
141
156
|
*/
|
|
142
157
|
get contextName(): string;
|
|
158
|
+
/**
|
|
159
|
+
* ipc/udp needs this
|
|
160
|
+
*/
|
|
161
|
+
get contextNameForCommunication(): string;
|
|
162
|
+
/**
|
|
163
|
+
* Check context type
|
|
164
|
+
*/
|
|
165
|
+
get contextType(): 'normal' | 'remote' | 'abstract' | 'invalid';
|
|
143
166
|
get cwd(): string;
|
|
144
167
|
get activeContext(): string | null;
|
|
145
168
|
get appId(): string;
|
|
@@ -148,7 +171,6 @@ export declare class EndpointContext {
|
|
|
148
171
|
locationOnDisk: string;
|
|
149
172
|
}[];
|
|
150
173
|
get isProductionMode(): boolean;
|
|
151
|
-
get remoteHost(): string;
|
|
152
174
|
get host(): string;
|
|
153
175
|
get orgin(): string;
|
|
154
176
|
initSubscribers(): Promise<void>;
|
|
@@ -157,9 +179,7 @@ export declare class EndpointContext {
|
|
|
157
179
|
initDatabaseConnection(): Promise<void>;
|
|
158
180
|
private updateCalculatedPathsForControllers;
|
|
159
181
|
private mergeControllerMethodsConfigs;
|
|
160
|
-
initControllersHook(
|
|
161
|
-
[contextName: string]: EndpointContext;
|
|
162
|
-
}): Promise<void>;
|
|
182
|
+
initControllersHook(ctxStorage: ContextsEndpointStorage): Promise<void>;
|
|
163
183
|
initControllers(): Promise<void>;
|
|
164
184
|
writeActiveRoutes(): void;
|
|
165
185
|
get middlewares(): Models.MiddlewareType[];
|
package/lib/endpoint-context.js
CHANGED
|
@@ -41,6 +41,7 @@ const symbols_1 = require("./symbols");
|
|
|
41
41
|
class EndpointContext {
|
|
42
42
|
originalConfig;
|
|
43
43
|
configFn;
|
|
44
|
+
cloneOptions;
|
|
44
45
|
//#region static
|
|
45
46
|
/**
|
|
46
47
|
* JUST FOR TESTING PURPOSES
|
|
@@ -94,6 +95,11 @@ class EndpointContext {
|
|
|
94
95
|
repos = new Map();
|
|
95
96
|
//#endregion
|
|
96
97
|
//#endregion
|
|
98
|
+
//#region fields / source context
|
|
99
|
+
get sourceContext() {
|
|
100
|
+
return this.cloneOptions?.sourceContext;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
97
103
|
skipWritingServerRoutes = false;
|
|
98
104
|
//#region fields / types from contexts
|
|
99
105
|
injectableTypesfromContexts = [
|
|
@@ -191,15 +197,24 @@ class EndpointContext {
|
|
|
191
197
|
* Inside docker there is not need for https secure server
|
|
192
198
|
*/
|
|
193
199
|
isRunningInsideDocker = false;
|
|
194
|
-
constructor(originalConfig, configFn
|
|
200
|
+
constructor(originalConfig, configFn,
|
|
201
|
+
/**
|
|
202
|
+
* (@default: false)
|
|
203
|
+
* If TRUE context is NOT going to create db/express server/http endpoints
|
|
204
|
+
* PURPOSE OF THIS PROPERTY
|
|
205
|
+
* -> ONLY remote access from backend or frontend to specific backend
|
|
206
|
+
*/
|
|
207
|
+
cloneOptions) {
|
|
195
208
|
this.originalConfig = originalConfig;
|
|
196
209
|
this.configFn = configFn;
|
|
210
|
+
this.cloneOptions = cloneOptions;
|
|
211
|
+
this.cloneOptions = this.cloneOptions || {};
|
|
197
212
|
this.isRunningInsideDocker = lib_9.UtilsOs.isRunningInDocker();
|
|
198
213
|
}
|
|
199
214
|
//#endregion
|
|
200
215
|
//#region methods & getters / init
|
|
201
216
|
async init(options) {
|
|
202
|
-
const { initFromRecrusiveContextResovle,
|
|
217
|
+
const { initFromRecrusiveContextResovle, onlyMigrationRun, onlyMigrationRevertToTimestamp, } = options || {}; // TODO use it ?
|
|
203
218
|
this.inited = true;
|
|
204
219
|
// @ts-ignore
|
|
205
220
|
this.onlyMigrationRun = onlyMigrationRun;
|
|
@@ -209,31 +224,23 @@ class EndpointContext {
|
|
|
209
224
|
if (lib_11._.isObject(this.config.database)) {
|
|
210
225
|
this.config.database = models_1.Models.DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
211
226
|
}
|
|
212
|
-
if (overrideHost && overrideRemoteHost) {
|
|
213
|
-
lib_11.Helpers.throw(`[taon-config] You can't have overrideHost and overrideRemoteHost at the same time`);
|
|
214
|
-
}
|
|
215
|
-
this.config.host = !lib_11._.isUndefined(overrideHost)
|
|
216
|
-
? overrideHost
|
|
217
|
-
: this.config.host;
|
|
218
|
-
this.config.remoteHost = !lib_11._.isUndefined(overrideRemoteHost)
|
|
219
|
-
? overrideRemoteHost
|
|
220
|
-
: this.config.remoteHost;
|
|
221
227
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
222
|
-
this.
|
|
223
|
-
this.
|
|
228
|
+
if (this.cloneOptions.overrideHost &&
|
|
229
|
+
!this.cloneOptions.useAsRemoteContext) {
|
|
230
|
+
this.config.host = this.cloneOptions.overrideHost;
|
|
231
|
+
}
|
|
232
|
+
if (this.cloneOptions.overrideRemoteHost &&
|
|
233
|
+
this.cloneOptions.useAsRemoteContext) {
|
|
234
|
+
this.config.host = this.cloneOptions.overrideRemoteHost;
|
|
235
|
+
}
|
|
224
236
|
if (this.config.host &&
|
|
225
237
|
!this.config.host.startsWith('http://') &&
|
|
226
238
|
!this.config.host.startsWith('https://')) {
|
|
227
|
-
lib_11.Helpers.throw(`[taon-config] Your 'host' must start with http:// or https://`);
|
|
239
|
+
lib_11.Helpers.throw(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
|
|
228
240
|
}
|
|
229
241
|
if (lib_11._.isUndefined(this.config.useIpcWhenElectron)) {
|
|
230
242
|
this.config.useIpcWhenElectron = true;
|
|
231
243
|
}
|
|
232
|
-
if (this.config.remoteHost &&
|
|
233
|
-
!this.config.remoteHost.startsWith('http://') &&
|
|
234
|
-
!this.config.remoteHost.startsWith('https://')) {
|
|
235
|
-
lib_11.Helpers.throw(`[taon-config] Your 'remoteHost' must start with http:// or https://`);
|
|
236
|
-
}
|
|
237
244
|
// console.log(`config for ${this.contextName}`, this.config);
|
|
238
245
|
//#region resolve if skipping writing server routes
|
|
239
246
|
//@ts-expect-error overriding readonly
|
|
@@ -247,10 +254,7 @@ class EndpointContext {
|
|
|
247
254
|
/* */
|
|
248
255
|
/* */
|
|
249
256
|
}
|
|
250
|
-
if (this.
|
|
251
|
-
if (this.config.host) {
|
|
252
|
-
lib_11.Helpers.throw(`[taon] You can't have remoteHost and host at the same time`);
|
|
253
|
-
}
|
|
257
|
+
if (this.isRemoteHost) {
|
|
254
258
|
this.mode = 'remote-backend(tcp+udp)';
|
|
255
259
|
}
|
|
256
260
|
// console.log(`
|
|
@@ -271,9 +275,9 @@ class EndpointContext {
|
|
|
271
275
|
// console.log(this.config)
|
|
272
276
|
// }
|
|
273
277
|
if (!this.mode && !this.config.abstract) {
|
|
274
|
-
const errMsg = `You need to provide host
|
|
275
|
-
`useIpcWhenElectron
|
|
276
|
-
lib_11.Helpers.error(`[taon]
|
|
278
|
+
const errMsg = `You need to provide host property or ` +
|
|
279
|
+
`useIpcWhenElectron or mark it as abstract`;
|
|
280
|
+
lib_11.Helpers.error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
|
|
277
281
|
//#region @backend
|
|
278
282
|
process.exit(1);
|
|
279
283
|
//#endregion
|
|
@@ -322,7 +326,7 @@ class EndpointContext {
|
|
|
322
326
|
axios_1.default.defaults.withCredentials = true;
|
|
323
327
|
}
|
|
324
328
|
//#endregion
|
|
325
|
-
//#region prepare & gather all classes
|
|
329
|
+
//#region prepare & gather all classes recursively
|
|
326
330
|
this.config.contexts = this.config.contexts || {};
|
|
327
331
|
this.config.entities = this.config.entities || {};
|
|
328
332
|
this.config.controllers = this.config.controllers || {};
|
|
@@ -450,6 +454,8 @@ class EndpointContext {
|
|
|
450
454
|
// Helpers.logInfo(`Realtime enabled on backend`);
|
|
451
455
|
// }
|
|
452
456
|
//#endregion
|
|
457
|
+
this.logRealtime &&
|
|
458
|
+
lib_11.Helpers.info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
|
|
453
459
|
this.realtime = new realtime_core_1.RealtimeCore(this);
|
|
454
460
|
}
|
|
455
461
|
//#endregion
|
|
@@ -461,9 +467,9 @@ class EndpointContext {
|
|
|
461
467
|
lib_11.Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
462
468
|
}
|
|
463
469
|
else {
|
|
464
|
-
if (this.
|
|
470
|
+
if (this.isRemoteHost) {
|
|
465
471
|
this.logFramework &&
|
|
466
|
-
lib_11.Helpers.info(`[taon] Create context for remote host: ${this.config.
|
|
472
|
+
lib_11.Helpers.info(`[taon] Create context for remote host: ${this.config.host}`);
|
|
467
473
|
}
|
|
468
474
|
else {
|
|
469
475
|
this.logFramework &&
|
|
@@ -614,7 +620,7 @@ class EndpointContext {
|
|
|
614
620
|
//#region methods & getters / start server
|
|
615
621
|
async startServer() {
|
|
616
622
|
//#region @backendFunc
|
|
617
|
-
if (this.
|
|
623
|
+
if (this.isRemoteHost || this.isRunOrRevertOnlyMigrationAppStart) {
|
|
618
624
|
return;
|
|
619
625
|
}
|
|
620
626
|
if (this.mode === 'backend-frontend(tcp+udp)') {
|
|
@@ -622,8 +628,10 @@ class EndpointContext {
|
|
|
622
628
|
if (this.isRunningInsideDocker) {
|
|
623
629
|
// this.displayRoutes(this.expressApp);
|
|
624
630
|
this.serverTcpUdp.listen(Number(this.uriPort), '0.0.0.0', () => {
|
|
625
|
-
|
|
626
|
-
|
|
631
|
+
this.logFramework &&
|
|
632
|
+
lib_11.Helpers.log(`[ctx=${this.contextName}] Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
|
|
633
|
+
this.logFramework &&
|
|
634
|
+
lib_11.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
627
635
|
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
628
636
|
ExpressJS mode: ${this.expressApp.settings.env}
|
|
629
637
|
`);
|
|
@@ -633,8 +641,10 @@ class EndpointContext {
|
|
|
633
641
|
else {
|
|
634
642
|
// this.displayRoutes(this.expressApp);
|
|
635
643
|
this.serverTcpUdp.listen(Number(this.uriPort), () => {
|
|
636
|
-
|
|
637
|
-
|
|
644
|
+
this.logFramework &&
|
|
645
|
+
lib_11.Helpers.log(`[ctx=${this.contextName}] Express server (inside nodejs app) started on localhost:${this.uriPort}`);
|
|
646
|
+
this.logFramework &&
|
|
647
|
+
lib_11.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
638
648
|
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
639
649
|
expressJS mode: ${this.expressApp.settings.env}
|
|
640
650
|
`);
|
|
@@ -974,7 +984,7 @@ class EndpointContext {
|
|
|
974
984
|
//#endregion
|
|
975
985
|
//#region methods & getters / init classes
|
|
976
986
|
async initClasses() {
|
|
977
|
-
if (this.
|
|
987
|
+
if (this.isRemoteHost) {
|
|
978
988
|
return;
|
|
979
989
|
}
|
|
980
990
|
//#region @websql
|
|
@@ -1037,11 +1047,7 @@ class EndpointContext {
|
|
|
1037
1047
|
return uri;
|
|
1038
1048
|
}
|
|
1039
1049
|
get uri() {
|
|
1040
|
-
const url = this.host
|
|
1041
|
-
? new url_1.URL(this.host)
|
|
1042
|
-
: this.remoteHost
|
|
1043
|
-
? new url_1.URL(this.remoteHost)
|
|
1044
|
-
: void 0;
|
|
1050
|
+
const url = this.host ? new url_1.URL(this.host) : void 0;
|
|
1045
1051
|
return url;
|
|
1046
1052
|
}
|
|
1047
1053
|
//#endregion
|
|
@@ -1109,11 +1115,50 @@ class EndpointContext {
|
|
|
1109
1115
|
}
|
|
1110
1116
|
//#endregion
|
|
1111
1117
|
//#region methods & getters / public assets
|
|
1118
|
+
get isRemoteHost() {
|
|
1119
|
+
return !!this.cloneOptions?.useAsRemoteContext;
|
|
1120
|
+
}
|
|
1121
|
+
//#endregion
|
|
1122
|
+
//#region methods & getters / public assets
|
|
1112
1123
|
/**
|
|
1113
1124
|
* ipc/udp needs this
|
|
1114
1125
|
*/
|
|
1115
1126
|
get contextName() {
|
|
1116
|
-
|
|
1127
|
+
// console.log(this.originalConfig);
|
|
1128
|
+
return this.config?.contextName || this.originalConfig?.contextName;
|
|
1129
|
+
}
|
|
1130
|
+
//#endregion
|
|
1131
|
+
//#region methods & getters / public assets
|
|
1132
|
+
/**
|
|
1133
|
+
* ipc/udp needs this
|
|
1134
|
+
*/
|
|
1135
|
+
get contextNameForCommunication() {
|
|
1136
|
+
let contextName = this.contextName;
|
|
1137
|
+
if (this.isRemoteHost) {
|
|
1138
|
+
if (this.sourceContext?.contextName) {
|
|
1139
|
+
contextName = this.sourceContext?.contextName;
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
// console.log(
|
|
1143
|
+
// `CANT GET SOURCE CONTEXT NAME FOR REMOTE CONTEXT ${this.contextName}`,
|
|
1144
|
+
// );
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
return contextName;
|
|
1148
|
+
}
|
|
1149
|
+
//#endregion
|
|
1150
|
+
//#region methods & getters / public assets
|
|
1151
|
+
/**
|
|
1152
|
+
* Check context type
|
|
1153
|
+
*/
|
|
1154
|
+
get contextType() {
|
|
1155
|
+
if (this.config.abstract) {
|
|
1156
|
+
return 'abstract';
|
|
1157
|
+
}
|
|
1158
|
+
if (this.host) {
|
|
1159
|
+
return this.isRemoteHost ? 'remote' : 'normal';
|
|
1160
|
+
}
|
|
1161
|
+
return 'invalid';
|
|
1117
1162
|
}
|
|
1118
1163
|
//#endregion
|
|
1119
1164
|
//#region methods & getters / current working directory
|
|
@@ -1141,11 +1186,6 @@ class EndpointContext {
|
|
|
1141
1186
|
return this.config.productionMode;
|
|
1142
1187
|
}
|
|
1143
1188
|
//#endregion
|
|
1144
|
-
//#region methods & getters / remote host
|
|
1145
|
-
get remoteHost() {
|
|
1146
|
-
return this.config.remoteHost;
|
|
1147
|
-
}
|
|
1148
|
-
//#endregion
|
|
1149
1189
|
//#region methods & getters / host
|
|
1150
1190
|
get host() {
|
|
1151
1191
|
return this.config.host;
|
|
@@ -1159,7 +1199,7 @@ class EndpointContext {
|
|
|
1159
1199
|
//#region methods & getters / init subscribers
|
|
1160
1200
|
async initSubscribers() {
|
|
1161
1201
|
//#region @websqlFunc
|
|
1162
|
-
if (this.
|
|
1202
|
+
if (this.isRemoteHost) {
|
|
1163
1203
|
return;
|
|
1164
1204
|
}
|
|
1165
1205
|
const subscriberClasses = this.getClassFunByArr(models_1.Models.ClassType.SUBSCRIBER);
|
|
@@ -1175,7 +1215,7 @@ class EndpointContext {
|
|
|
1175
1215
|
//#region methods & getters / init entities
|
|
1176
1216
|
async initEntities() {
|
|
1177
1217
|
//#region @websql
|
|
1178
|
-
if (this.
|
|
1218
|
+
if (this.isRemoteHost) {
|
|
1179
1219
|
return;
|
|
1180
1220
|
}
|
|
1181
1221
|
const entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY);
|
|
@@ -1221,7 +1261,7 @@ class EndpointContext {
|
|
|
1221
1261
|
//#region methods & getters / init connection
|
|
1222
1262
|
async initDatabaseConnection() {
|
|
1223
1263
|
//#region @websqlFunc
|
|
1224
|
-
if (this.
|
|
1264
|
+
if (this.isRemoteHost || !this.databaseConfig) {
|
|
1225
1265
|
return;
|
|
1226
1266
|
}
|
|
1227
1267
|
const entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY).map(entityFn => {
|
|
@@ -1328,12 +1368,13 @@ class EndpointContext {
|
|
|
1328
1368
|
return bc.className;
|
|
1329
1369
|
})
|
|
1330
1370
|
.join('/');
|
|
1371
|
+
const contextNameForCommunication = this.contextNameForCommunication;
|
|
1331
1372
|
if (taon_helpers_1.TaonHelpers.isGoodPath(classConfig.path)) {
|
|
1332
1373
|
classConfig.calculatedPath = classConfig.path;
|
|
1333
1374
|
}
|
|
1334
1375
|
else {
|
|
1335
1376
|
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
1336
|
-
`/${constants_1.apiPrefix}/${
|
|
1377
|
+
`/${constants_1.apiPrefix}/${contextNameForCommunication}/tcp${parentsCalculatedPath}/` +
|
|
1337
1378
|
`${class_helpers_1.ClassHelpers.getName(controllerClassFn)}`)
|
|
1338
1379
|
.replace(/\/\//g, '/')
|
|
1339
1380
|
.split('/')
|
|
@@ -1363,7 +1404,7 @@ class EndpointContext {
|
|
|
1363
1404
|
});
|
|
1364
1405
|
}
|
|
1365
1406
|
//#endregion
|
|
1366
|
-
async initControllersHook(
|
|
1407
|
+
async initControllersHook(ctxStorage) {
|
|
1367
1408
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
1368
1409
|
return;
|
|
1369
1410
|
}
|
|
@@ -1371,7 +1412,7 @@ class EndpointContext {
|
|
|
1371
1412
|
for (const controllerClassFn of allControllers) {
|
|
1372
1413
|
const instance = this.getInstanceBy(controllerClassFn);
|
|
1373
1414
|
if (lib_11._.isFunction(instance.afterAllCtxInited)) {
|
|
1374
|
-
await instance.afterAllCtxInited(
|
|
1415
|
+
await instance.afterAllCtxInited({ ctxStorage });
|
|
1375
1416
|
}
|
|
1376
1417
|
}
|
|
1377
1418
|
}
|
|
@@ -1471,7 +1512,7 @@ class EndpointContext {
|
|
|
1471
1512
|
}
|
|
1472
1513
|
//#endregion
|
|
1473
1514
|
//#region init client
|
|
1474
|
-
const shouldInitClient = lib_11.Helpers.isBrowser || this.
|
|
1515
|
+
const shouldInitClient = lib_11.Helpers.isBrowser || this.isRemoteHost || lib_11.Helpers.isWebSQL;
|
|
1475
1516
|
// console.log('shouldInitClient', shouldInitClient);
|
|
1476
1517
|
if (shouldInitClient) {
|
|
1477
1518
|
// console.log(
|
|
@@ -1500,7 +1541,7 @@ class EndpointContext {
|
|
|
1500
1541
|
//#endregion
|
|
1501
1542
|
//#region methods & getters / write active routes
|
|
1502
1543
|
writeActiveRoutes() {
|
|
1503
|
-
if (this.
|
|
1544
|
+
if (this.isRemoteHost ||
|
|
1504
1545
|
this.isRunOrRevertOnlyMigrationAppStart ||
|
|
1505
1546
|
this.skipWritingServerRoutes) {
|
|
1506
1547
|
return;
|
|
@@ -1742,7 +1783,7 @@ class EndpointContext {
|
|
|
1742
1783
|
};
|
|
1743
1784
|
//#endregion
|
|
1744
1785
|
}
|
|
1745
|
-
if (!this.
|
|
1786
|
+
if (!this.isRemoteHost) {
|
|
1746
1787
|
//#region apply dummy websql express routers
|
|
1747
1788
|
//#region @websql
|
|
1748
1789
|
if (lib_11.Helpers.isWebSQL) {
|