taon 19.0.65 → 19.0.67

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.
Files changed (97) hide show
  1. package/README.md +160 -160
  2. package/bin/start.js +281 -281
  3. package/bin/taon +6 -6
  4. package/bin/taon-debug +5 -5
  5. package/bin/taon-debug-brk +5 -5
  6. package/browser/README.md +24 -24
  7. package/browser/fesm2022/taon.mjs +288 -81
  8. package/browser/fesm2022/taon.mjs.map +1 -1
  9. package/browser/lib/base-classes/base-class.d.ts +8 -1
  10. package/browser/lib/base-classes/base-controller.d.ts +56 -4
  11. package/browser/lib/base-classes/base-crud-controller.d.ts +5 -4
  12. package/browser/lib/base-classes/base-repository.d.ts +3 -0
  13. package/browser/lib/config/method-config.d.ts +1 -0
  14. package/browser/lib/decorators/http/http-decorators.d.ts +2 -1
  15. package/browser/lib/decorators/http/http-methods-decorators.d.ts +35 -4
  16. package/browser/lib/decorators/http/http-params-decorators.d.ts +3 -0
  17. package/browser/lib/endpoint-context.d.ts +3 -0
  18. package/browser/lib/get-response-value.d.ts +1 -1
  19. package/browser/lib/helpers/taon-helpers.d.ts +1 -0
  20. package/browser/lib/index.d.ts +4 -0
  21. package/browser/lib/models.d.ts +4 -10
  22. package/browser/lib/realtime/realtime-client.d.ts +18 -14
  23. package/browser/lib/realtime/realtime-server.d.ts +28 -3
  24. package/browser/lib/realtime/realtime.models.d.ts +15 -2
  25. package/browser/package.json +1 -1
  26. package/icon-menu-taon.svg +15 -15
  27. package/lib/base-classes/base-class.d.ts +8 -1
  28. package/lib/base-classes/base-class.js +20 -2
  29. package/lib/base-classes/base-class.js.map +1 -1
  30. package/lib/base-classes/base-controller.d.ts +57 -5
  31. package/lib/base-classes/base-controller.js +83 -12
  32. package/lib/base-classes/base-controller.js.map +1 -1
  33. package/lib/base-classes/base-crud-controller.d.ts +5 -4
  34. package/lib/base-classes/base-crud-controller.js +29 -17
  35. package/lib/base-classes/base-crud-controller.js.map +1 -1
  36. package/lib/base-classes/base-repository.d.ts +3 -0
  37. package/lib/base-classes/base-repository.js +3 -0
  38. package/lib/base-classes/base-repository.js.map +1 -1
  39. package/lib/build-info._auto-generated_.d.ts +1 -1
  40. package/lib/build-info._auto-generated_.js +1 -1
  41. package/lib/config/method-config.d.ts +1 -0
  42. package/lib/config/method-config.js.map +1 -1
  43. package/lib/decorators/http/http-decorators.d.ts +2 -1
  44. package/lib/decorators/http/http-decorators.js +2 -1
  45. package/lib/decorators/http/http-decorators.js.map +1 -1
  46. package/lib/decorators/http/http-methods-decorators.d.ts +35 -4
  47. package/lib/decorators/http/http-methods-decorators.js +34 -1
  48. package/lib/decorators/http/http-methods-decorators.js.map +1 -1
  49. package/lib/decorators/http/http-params-decorators.d.ts +3 -0
  50. package/lib/decorators/http/http-params-decorators.js +3 -0
  51. package/lib/decorators/http/http-params-decorators.js.map +1 -1
  52. package/lib/endpoint-context.d.ts +3 -0
  53. package/lib/endpoint-context.js +152 -122
  54. package/lib/endpoint-context.js.map +1 -1
  55. package/lib/get-response-value.d.ts +1 -1
  56. package/lib/get-response-value.js +0 -4
  57. package/lib/get-response-value.js.map +1 -1
  58. package/lib/helpers/taon-helpers.d.ts +1 -0
  59. package/lib/helpers/taon-helpers.js +6 -0
  60. package/lib/helpers/taon-helpers.js.map +1 -1
  61. package/lib/index.d.ts +4 -0
  62. package/lib/index.js +8 -2
  63. package/lib/index.js.map +1 -1
  64. package/lib/models.d.ts +4 -10
  65. package/lib/models.js +5 -23
  66. package/lib/models.js.map +1 -1
  67. package/lib/realtime/realtime-client.d.ts +18 -14
  68. package/lib/realtime/realtime-client.js +33 -25
  69. package/lib/realtime/realtime-client.js.map +1 -1
  70. package/lib/realtime/realtime-server.d.ts +28 -3
  71. package/lib/realtime/realtime-server.js +28 -2
  72. package/lib/realtime/realtime-server.js.map +1 -1
  73. package/lib/realtime/realtime.models.d.ts +15 -2
  74. package/lib/ui/index.js +2 -2
  75. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  76. package/package.json +1 -1
  77. package/scss/global.scss +9 -12
  78. package/websql/README.md +24 -24
  79. package/websql/fesm2022/taon.mjs +289 -83
  80. package/websql/fesm2022/taon.mjs.map +1 -1
  81. package/websql/lib/base-classes/base-class.d.ts +8 -1
  82. package/websql/lib/base-classes/base-controller.d.ts +56 -4
  83. package/websql/lib/base-classes/base-crud-controller.d.ts +5 -4
  84. package/websql/lib/base-classes/base-repository.d.ts +3 -0
  85. package/websql/lib/config/method-config.d.ts +1 -0
  86. package/websql/lib/decorators/http/http-decorators.d.ts +2 -1
  87. package/websql/lib/decorators/http/http-methods-decorators.d.ts +35 -4
  88. package/websql/lib/decorators/http/http-params-decorators.d.ts +3 -0
  89. package/websql/lib/endpoint-context.d.ts +3 -0
  90. package/websql/lib/get-response-value.d.ts +1 -1
  91. package/websql/lib/helpers/taon-helpers.d.ts +1 -0
  92. package/websql/lib/index.d.ts +4 -0
  93. package/websql/lib/models.d.ts +4 -10
  94. package/websql/lib/realtime/realtime-client.d.ts +18 -14
  95. package/websql/lib/realtime/realtime-server.d.ts +28 -3
  96. package/websql/lib/realtime/realtime.models.d.ts +15 -2
  97. package/websql/package.json +1 -1
@@ -21,11 +21,12 @@ const lib_4 = require("taon-typeorm/lib"); // @websql
21
21
  const lib_5 = require("taon-typeorm/lib"); // @websql
22
22
  const lib_6 = require("taon-typeorm/lib");
23
23
  const lib_7 = require("tnp-config/lib");
24
- const lib_8 = require("tnp-core/lib"); // @backend
25
- const lib_9 = require("tnp-core/lib");
24
+ const lib_8 = require("tnp-core/lib");
25
+ const lib_9 = require("tnp-core/lib"); // @backend
26
26
  const lib_10 = require("tnp-core/lib");
27
27
  const lib_11 = require("tnp-core/lib");
28
28
  const lib_12 = require("tnp-core/lib");
29
+ const lib_13 = require("tnp-core/lib");
29
30
  const constants_1 = require("./constants");
30
31
  const context_db_migrations_1 = require("./context-db-migrations");
31
32
  const di_container_1 = require("./dependency-injection/di-container");
@@ -161,31 +162,37 @@ class EndpointContext {
161
162
  //#endregion
162
163
  //#region fields / logs
163
164
  get logHttp() {
164
- if (lib_11._.isObject(this.config?.logs)) {
165
+ if (lib_12._.isObject(this.config?.logs)) {
165
166
  return !!this.config.logs.http;
166
167
  }
167
168
  return this.config?.logs === true;
168
169
  }
169
170
  get logRealtime() {
170
- if (lib_11._.isObject(this.config?.logs)) {
171
+ if (lib_12._.isObject(this.config?.logs)) {
171
172
  return !!this.config.logs.realtime;
172
173
  }
173
174
  return this.config?.logs === true;
174
175
  }
175
176
  get logFramework() {
176
- if (lib_11._.isObject(this.config?.logs)) {
177
+ if (lib_12._.isObject(this.config?.logs)) {
177
178
  return !!this.config.logs.framework;
178
179
  }
179
180
  return this.config?.logs === true;
180
181
  }
182
+ get logRoutes() {
183
+ if (lib_12._.isObject(this.config?.logs)) {
184
+ return !!this.config.logs.routes;
185
+ }
186
+ return this.config?.logs === true;
187
+ }
181
188
  get logDb() {
182
- if (lib_11._.isObject(this.config?.logs)) {
189
+ if (lib_12._.isObject(this.config?.logs)) {
183
190
  return !!this.config.logs.db;
184
191
  }
185
192
  return this.config?.logs === true;
186
193
  }
187
194
  get logMigrations() {
188
- if (lib_11._.isObject(this.config?.logs)) {
195
+ if (lib_12._.isObject(this.config?.logs)) {
189
196
  return !!this.config.logs.migrations;
190
197
  }
191
198
  return this.config?.logs === true;
@@ -209,7 +216,7 @@ class EndpointContext {
209
216
  this.configFn = configFn;
210
217
  this.cloneOptions = cloneOptions;
211
218
  this.cloneOptions = this.cloneOptions || {};
212
- this.isRunningInsideDocker = lib_9.UtilsOs.isRunningInDocker();
219
+ this.isRunningInsideDocker = lib_10.UtilsOs.isRunningInDocker();
213
220
  }
214
221
  //#endregion
215
222
  //#region methods & getters / init
@@ -221,7 +228,7 @@ class EndpointContext {
221
228
  // @ts-ignore
222
229
  this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
223
230
  this.config = this.configFn({});
224
- if (lib_11._.isObject(this.config.database)) {
231
+ if (lib_12._.isObject(this.config.database)) {
225
232
  this.config.database = models_1.Models.DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
226
233
  }
227
234
  this.config.host = this.host === null ? void 0 : this.host;
@@ -236,15 +243,15 @@ class EndpointContext {
236
243
  if (this.config.host &&
237
244
  !this.config.host.startsWith('http://') &&
238
245
  !this.config.host.startsWith('https://')) {
239
- lib_11.Helpers.throw(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
246
+ lib_12.Helpers.throw(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
240
247
  }
241
- if (lib_11._.isUndefined(this.config.useIpcWhenElectron)) {
248
+ if (lib_12._.isUndefined(this.config.useIpcWhenElectron)) {
242
249
  this.config.useIpcWhenElectron = true;
243
250
  }
244
251
  // console.log(`config for ${this.contextName}`, this.config);
245
252
  //#region resolve if skipping writing server routes
246
253
  //@ts-expect-error overriding readonly
247
- this.skipWritingServerRoutes = lib_11._.isBoolean(this.config.skipWritingServerRoutes)
254
+ this.skipWritingServerRoutes = lib_12._.isBoolean(this.config.skipWritingServerRoutes)
248
255
  ? this.config.skipWritingServerRoutes
249
256
  : false;
250
257
  //#endregion
@@ -261,8 +268,8 @@ class EndpointContext {
261
268
  // useIpcWhenElectron: ${this.config.useIpcWhenElectron}
262
269
  // Helpers.isElectron: ${Helpers.isElectron}
263
270
  // `)
264
- if (this.config.useIpcWhenElectron && lib_11.Helpers.isElectron) {
265
- if (lib_11.Helpers.isWebSQL) {
271
+ if (this.config.useIpcWhenElectron && lib_12.Helpers.isElectron) {
272
+ if (lib_12.Helpers.isWebSQL) {
266
273
  this.mode = 'backend-frontend(websql-electron)';
267
274
  }
268
275
  else {
@@ -277,7 +284,7 @@ class EndpointContext {
277
284
  if (!this.mode && !this.config.abstract) {
278
285
  const errMsg = `You need to provide host property or ` +
279
286
  `useIpcWhenElectron or mark it as abstract`;
280
- lib_11.Helpers.error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
287
+ lib_12.Helpers.error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
281
288
  //#region @backend
282
289
  process.exit(1);
283
290
  //#endregion
@@ -293,7 +300,7 @@ class EndpointContext {
293
300
  `);
294
301
  this.databaseConfig = this.getAutoGeneratedConfig();
295
302
  }
296
- else if (lib_11._.isObject(this.config.database)) {
303
+ else if (lib_12._.isObject(this.config.database)) {
297
304
  this.logFramework &&
298
305
  console.log(`
299
306
 
@@ -302,13 +309,13 @@ class EndpointContext {
302
309
  `);
303
310
  this.databaseConfig = this.getAutoGeneratedConfig();
304
311
  lib_2.walk.Object(this.config.database, (value, lodashPath) => {
305
- if (lib_11._.isNil(value) || lib_11._.isFunction(value) || lib_11._.isObject(value)) {
312
+ if (lib_12._.isNil(value) || lib_12._.isFunction(value) || lib_12._.isObject(value)) {
306
313
  // skipping
307
314
  }
308
315
  else {
309
316
  this.logFramework &&
310
317
  console.info(`Overriding database config: ${lodashPath}=${value}`);
311
- lib_11._.set(this.databaseConfig, lodashPath, value);
318
+ lib_12._.set(this.databaseConfig, lodashPath, value);
312
319
  }
313
320
  }, {
314
321
  walkGetters: false,
@@ -317,7 +324,7 @@ class EndpointContext {
317
324
  //#endregion
318
325
  //#region resolve session
319
326
  if (this.config.session) {
320
- this.session = lib_11._.cloneDeep(this.config.session);
327
+ this.session = lib_12._.cloneDeep(this.config.session);
321
328
  const oneHour = 1000 * 60 * 60 * 1; // 24;
322
329
  if (!this.session.cookieMaxAge) {
323
330
  this.session.cookieMaxAge = oneHour;
@@ -424,17 +431,17 @@ class EndpointContext {
424
431
  await this.initCustomBackendMiddlewares();
425
432
  const shouldStartHttpsSecureServer = this.isHttpServer && !this.isRunningInsideDocker;
426
433
  this.logFramework &&
427
- lib_11.Helpers.info(`
434
+ lib_12.Helpers.info(`
428
435
 
429
436
  Starting server ${shouldStartHttpsSecureServer ? 'with' : 'without'} HTTPS secure server
430
437
 
431
438
  `);
432
439
  this.serverTcpUdp = shouldStartHttpsSecureServer
433
- ? new lib_8.https.Server({
440
+ ? new lib_9.https.Server({
434
441
  key: this.config.https?.key,
435
442
  cert: this.config.https?.cert,
436
443
  }, this.expressApp)
437
- : new lib_8.http.Server(this.expressApp);
444
+ : new lib_9.http.Server(this.expressApp);
438
445
  this.publicAssets.forEach(asset => {
439
446
  this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
440
447
  });
@@ -455,7 +462,7 @@ class EndpointContext {
455
462
  // }
456
463
  //#endregion
457
464
  this.logRealtime &&
458
- lib_11.Helpers.info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
465
+ lib_12.Helpers.info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
459
466
  this.realtime = new realtime_core_1.RealtimeCore(this);
460
467
  }
461
468
  //#endregion
@@ -464,16 +471,16 @@ class EndpointContext {
464
471
  // console.log({ ref })
465
472
  if (this.config.abstract) {
466
473
  this.logFramework &&
467
- lib_11.Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
474
+ lib_12.Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
468
475
  }
469
476
  else {
470
477
  if (this.isRemoteHost) {
471
478
  this.logFramework &&
472
- lib_11.Helpers.info(`[taon] Create context for remote host: ${this.config.host}`);
479
+ lib_12.Helpers.info(`[taon] Create context for remote host: ${this.config.host}`);
473
480
  }
474
481
  else {
475
482
  this.logFramework &&
476
- lib_11.Helpers.info(`[taon] Create context for host: ${this.config.host}`);
483
+ lib_12.Helpers.info(`[taon] Create context for host: ${this.config.host}`);
477
484
  }
478
485
  }
479
486
  //#endregion
@@ -518,7 +525,7 @@ class EndpointContext {
518
525
 
519
526
  `);
520
527
  //#region @backend
521
- const locationOfTheDatabase = (0, lib_10.crossPlatformPath)([
528
+ const locationOfTheDatabase = (0, lib_11.crossPlatformPath)([
522
529
  process.cwd(),
523
530
  `db-${this.contextName}.sqlite`,
524
531
  ]);
@@ -531,14 +538,14 @@ class EndpointContext {
531
538
  logging: true,
532
539
  });
533
540
  //#region @backend
534
- if (!lib_8.fse.existsSync(locationOfTheDatabase)) {
541
+ if (!lib_9.fse.existsSync(locationOfTheDatabase)) {
535
542
  databaseConfig.recreateMode = 'DROP_DB+MIGRATIONS';
536
543
  }
537
544
  // TODO @LAST add same thing for mariadb/mysql
538
545
  this.logFramework &&
539
546
  console.log(`
540
547
  location of database: ${locationOfTheDatabase}
541
- db file exists: ${lib_8.fse.existsSync(locationOfTheDatabase)}
548
+ db file exists: ${lib_9.fse.existsSync(locationOfTheDatabase)}
542
549
  synchronize: ${databaseConfig.synchronize}
543
550
  dropSchema: ${databaseConfig.dropSchema}
544
551
  `);
@@ -548,24 +555,24 @@ class EndpointContext {
548
555
  else {
549
556
  //#region auto resolve db config
550
557
  this.logFramework &&
551
- lib_11.Helpers.info(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
558
+ lib_12.Helpers.info(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
552
559
  switch (this.mode) {
553
560
  //#region resolve database config for backend-frontend(ipc-electron)
554
561
  case 'backend-frontend(ipc-electron)':
555
562
  let dbLocationInOs;
556
563
  //#region @backend
557
- if (lib_9.UtilsOs.isElectron) {
558
- dbLocationInOs = (0, lib_10.crossPlatformPath)([
559
- lib_9.UtilsOs.getRealHomeDir(),
560
- `.taon/databases-for-electron-apps/${this.appId || lib_11._.snakeCase(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
564
+ if (lib_10.UtilsOs.isElectron) {
565
+ dbLocationInOs = (0, lib_11.crossPlatformPath)([
566
+ lib_10.UtilsOs.getRealHomeDir(),
567
+ `.taon/databases-for-electron-apps/${this.appId || lib_12._.snakeCase(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
561
568
  ]);
562
- if (!lib_11.Helpers.exists(lib_12.path.dirname(dbLocationInOs))) {
563
- lib_11.Helpers.mkdirp(lib_12.path.dirname(dbLocationInOs));
569
+ if (!lib_12.Helpers.exists(lib_13.path.dirname(dbLocationInOs))) {
570
+ lib_12.Helpers.mkdirp(lib_13.path.dirname(dbLocationInOs));
564
571
  }
565
572
  }
566
573
  //#endregion
567
574
  databaseConfig = models_1.Models.DatabaseConfig.from({
568
- location: lib_9.UtilsOs.isElectron
575
+ location: lib_10.UtilsOs.isElectron
569
576
  ? dbLocationInOs
570
577
  : `db-${this.contextName}.sqlite`,
571
578
  type: 'sqljs',
@@ -629,9 +636,9 @@ class EndpointContext {
629
636
  // this.displayRoutes(this.expressApp);
630
637
  this.serverTcpUdp.listen(Number(this.uriPort), '0.0.0.0', () => {
631
638
  this.logFramework &&
632
- lib_11.Helpers.log(`[ctx=${this.contextName}] Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
639
+ lib_12.Helpers.log(`[ctx=${this.contextName}] Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
633
640
  this.logFramework &&
634
- lib_11.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
641
+ lib_12.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
635
642
  address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
636
643
  ExpressJS mode: ${this.expressApp.settings.env}
637
644
  `);
@@ -642,9 +649,9 @@ class EndpointContext {
642
649
  // this.displayRoutes(this.expressApp);
643
650
  this.serverTcpUdp.listen(Number(this.uriPort), () => {
644
651
  this.logFramework &&
645
- lib_11.Helpers.log(`[ctx=${this.contextName}] Express server (inside nodejs app) started on localhost:${this.uriPort}`);
652
+ lib_12.Helpers.log(`[ctx=${this.contextName}] Express server (inside nodejs app) started on localhost:${this.uriPort}`);
646
653
  this.logFramework &&
647
- lib_11.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
654
+ lib_12.Helpers.log(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
648
655
  address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
649
656
  expressJS mode: ${this.expressApp.settings.env}
650
657
  `);
@@ -655,7 +662,7 @@ class EndpointContext {
655
662
  }
656
663
  else {
657
664
  this.logFramework &&
658
- lib_11.Helpers.info('Ipc communication enable instead tcp/upd');
665
+ lib_12.Helpers.info('Ipc communication enable instead tcp/upd');
659
666
  }
660
667
  //#endregion
661
668
  }
@@ -763,7 +770,7 @@ class EndpointContext {
763
770
  for (const key of Object.keys(classesInput || {})) {
764
771
  const BaseClass = classesInput[key];
765
772
  if (!BaseClass) {
766
- lib_11.Helpers.error(`Class ${key} is not defined in context ${ctx.contextName}
773
+ lib_12.Helpers.error(`Class ${key} is not defined in context ${ctx.contextName}
767
774
 
768
775
  Please check if you have correct import in context file
769
776
 
@@ -842,7 +849,7 @@ class EndpointContext {
842
849
  let entityName = '';
843
850
  // entity thing is only for repositories local repositories
844
851
  // if (className === 'BaseRepository') {
845
- const entityFn = lib_11._.first(locaInstanceConstructorArgs);
852
+ const entityFn = lib_12._.first(locaInstanceConstructorArgs);
846
853
  const entity = entityFn && entityFn();
847
854
  entityName = (entity && class_helpers_1.ClassHelpers.getName(entity)) || '';
848
855
  // console.log(`entityName `, entityName);
@@ -905,7 +912,7 @@ class EndpointContext {
905
912
  //#endregion
906
913
  //#region methods & getters / check if context initialized
907
914
  checkIfContextInitialized() {
908
- if (lib_11._.isUndefined(this.config)) {
915
+ if (lib_12._.isUndefined(this.config)) {
909
916
  throw new Error(`Please check if your context has been initialized.
910
917
 
911
918
  // ...
@@ -1003,7 +1010,7 @@ class EndpointContext {
1003
1010
  ]) {
1004
1011
  //#region init class static _ property
1005
1012
  for (const classFun of this.getClassFunByArr(classTypeName)) {
1006
- if (lib_11._.isFunction(classFun._)) {
1013
+ if (lib_12._.isFunction(classFun._)) {
1007
1014
  await classFun._();
1008
1015
  }
1009
1016
  }
@@ -1021,7 +1028,7 @@ class EndpointContext {
1021
1028
  // `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
1022
1029
  // );
1023
1030
  for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
1024
- if (lib_11._.isFunction(ctrl._)) {
1031
+ if (lib_12._.isFunction(ctrl._)) {
1025
1032
  await ctrl._();
1026
1033
  }
1027
1034
  }
@@ -1221,7 +1228,7 @@ class EndpointContext {
1221
1228
  const entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY);
1222
1229
  for (const entity of entities) {
1223
1230
  const options = Reflect.getMetadata(symbols_1.Symbols.metadata.options.entity, entity);
1224
- const createTable = lib_11._.isUndefined(options.createTable)
1231
+ const createTable = lib_12._.isUndefined(options.createTable)
1225
1232
  ? true
1226
1233
  : options.createTable;
1227
1234
  const nameForEntity = class_helpers_1.ClassHelpers.getName(entity);
@@ -1269,7 +1276,7 @@ class EndpointContext {
1269
1276
  });
1270
1277
  const subscribers = this.getClassFunByArr(models_1.Models.ClassType.SUBSCRIBER);
1271
1278
  let autoSave = false;
1272
- if (!lib_11._.isNil(this.databaseConfig.autoSave)) {
1279
+ if (!lib_12._.isNil(this.databaseConfig.autoSave)) {
1273
1280
  autoSave = this.databaseConfig.autoSave;
1274
1281
  }
1275
1282
  else {
@@ -1280,7 +1287,7 @@ class EndpointContext {
1280
1287
  autoSave = true; // on docker with sqljs I need to save db
1281
1288
  }
1282
1289
  }
1283
- const dataSourceDbConfig = lib_11._.isObject(this.databaseConfig)
1290
+ const dataSourceDbConfig = lib_12._.isObject(this.databaseConfig)
1284
1291
  ? {
1285
1292
  type: this.databaseConfig.type,
1286
1293
  port: this.databaseConfig.databasePort,
@@ -1309,7 +1316,7 @@ class EndpointContext {
1309
1316
  if (this.modeAllowsDatabaseCreation && this.databaseConfig) {
1310
1317
  this.logDb &&
1311
1318
  this.logFramework &&
1312
- lib_11.Helpers.info('[taon][database] prepare typeorm connection...');
1319
+ lib_12.Helpers.info('[taon][database] prepare typeorm connection...');
1313
1320
  try {
1314
1321
  const connection = new lib_6.DataSource(dataSourceDbConfig);
1315
1322
  this.connection = connection;
@@ -1351,7 +1358,7 @@ class EndpointContext {
1351
1358
  // debugger;
1352
1359
  }
1353
1360
  else {
1354
- lib_11.Helpers.info(`[taon][typeorm] Not initing db for mode ${this.mode}`);
1361
+ lib_12.Helpers.info(`[taon][typeorm] Not initing db for mode ${this.mode}`);
1355
1362
  }
1356
1363
  //#endregion
1357
1364
  }
@@ -1359,7 +1366,7 @@ class EndpointContext {
1359
1366
  //#region methods & getters / initialize metadata
1360
1367
  //#region methods & getters / update class calculate path
1361
1368
  updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn) {
1362
- const parentsCalculatedPath = lib_11._.slice(rawConfigs, 1)
1369
+ const parentsCalculatedPath = lib_12._.slice(rawConfigs, 1)
1363
1370
  .reverse()
1364
1371
  .map(bc => {
1365
1372
  if (taon_helpers_1.TaonHelpers.isGoodPath(bc.path)) {
@@ -1379,7 +1386,7 @@ class EndpointContext {
1379
1386
  .replace(/\/\//g, '/')
1380
1387
  .split('/')
1381
1388
  .reduce((acc, bc) => {
1382
- return lib_11._.last(acc) === bc ? acc : [...acc, bc];
1389
+ return lib_12._.last(acc) === bc ? acc : [...acc, bc];
1383
1390
  }, [])
1384
1391
  .join('/');
1385
1392
  }
@@ -1389,8 +1396,8 @@ class EndpointContext {
1389
1396
  //#region methods & getters / dedupe class configs
1390
1397
  mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn) {
1391
1398
  const currentControllerMethodsConfig = classConfig.methods;
1392
- lib_11._.slice(rawConfigs, 1).forEach(bc => {
1393
- const parentControllerMethods = lib_11._.cloneDeep(bc.methods);
1399
+ lib_12._.slice(rawConfigs, 1).forEach(bc => {
1400
+ const parentControllerMethods = lib_12._.cloneDeep(bc.methods);
1394
1401
  for (const methodsName in parentControllerMethods) {
1395
1402
  if (parentControllerMethods.hasOwnProperty(methodsName)) {
1396
1403
  if (!currentControllerMethodsConfig[methodsName]) {
@@ -1411,7 +1418,7 @@ class EndpointContext {
1411
1418
  const allControllers = this.getClassFunByArr(models_1.Models.ClassType.CONTROLLER);
1412
1419
  for (const controllerClassFn of allControllers) {
1413
1420
  const instance = this.getInstanceBy(controllerClassFn);
1414
- if (lib_11._.isFunction(instance.afterAllCtxInited)) {
1421
+ if (lib_12._.isFunction(instance.afterAllCtxInited)) {
1415
1422
  await instance.afterAllCtxInited({ ctxStorage });
1416
1423
  }
1417
1424
  }
@@ -1441,7 +1448,7 @@ class EndpointContext {
1441
1448
  //#region combine middlewares from controllers
1442
1449
  classConfig.calculatedMiddlewaresControllerObj = {};
1443
1450
  [...rawConfigs].reverse().forEach(rc => {
1444
- if (lib_11._.isFunction(rc.middlewares)) {
1451
+ if (lib_12._.isFunction(rc.middlewares)) {
1445
1452
  classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
1446
1453
  parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
1447
1454
  className(middlewareClass) {
@@ -1453,7 +1460,7 @@ class EndpointContext {
1453
1460
  //#endregion
1454
1461
  //#region group start
1455
1462
  //#region @backend
1456
- if (!lib_11.Helpers.isRunningIn.cliMode()) {
1463
+ if (!lib_12.Helpers.isRunningIn.cliMode()) {
1457
1464
  //#endregion
1458
1465
  this.logHttp &&
1459
1466
  console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
@@ -1470,7 +1477,7 @@ class EndpointContext {
1470
1477
  [...rawConfigs].reverse().forEach(rc => {
1471
1478
  if (rc.methods[methodName]) {
1472
1479
  const parentMethodConfig = rc.methods[methodName];
1473
- if (lib_11._.isFunction(parentMethodConfig.middlewares)) {
1480
+ if (lib_12._.isFunction(parentMethodConfig.middlewares)) {
1474
1481
  calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
1475
1482
  parentMiddlewares: calculatedMiddlewaresMethodObj,
1476
1483
  className(middlewareClass) {
@@ -1501,7 +1508,7 @@ class EndpointContext {
1501
1508
  //#endregion
1502
1509
  //#region init server
1503
1510
  // console.log({ expressPath });
1504
- if (lib_11.Helpers.isNode || lib_11.Helpers.isWebSQL) {
1511
+ if (lib_12.Helpers.isNode || lib_12.Helpers.isWebSQL) {
1505
1512
  //#region @websql
1506
1513
  const route = this.initServer(httpMethodType, methodConfig, classConfig, expressPath, controllerClassFn);
1507
1514
  this.activeRoutes.push({
@@ -1512,7 +1519,7 @@ class EndpointContext {
1512
1519
  }
1513
1520
  //#endregion
1514
1521
  //#region init client
1515
- const shouldInitClient = lib_11.Helpers.isBrowser || this.isRemoteHost || lib_11.Helpers.isWebSQL;
1522
+ const shouldInitClient = lib_12.Helpers.isBrowser || this.isRemoteHost || lib_12.Helpers.isWebSQL;
1516
1523
  // console.log('shouldInitClient', shouldInitClient);
1517
1524
  if (shouldInitClient) {
1518
1525
  // console.log(
@@ -1529,7 +1536,7 @@ class EndpointContext {
1529
1536
  //#endregion
1530
1537
  //#region group end
1531
1538
  //#region @backend
1532
- if (!lib_11.Helpers.isRunningIn.cliMode()) {
1539
+ if (!lib_12.Helpers.isRunningIn.cliMode()) {
1533
1540
  //#endregion
1534
1541
  this.logHttp && console.groupEnd();
1535
1542
  //#region @backend
@@ -1541,18 +1548,16 @@ class EndpointContext {
1541
1548
  //#endregion
1542
1549
  //#region methods & getters / write active routes
1543
1550
  writeActiveRoutes() {
1544
- if (this.isRemoteHost ||
1545
- this.isRunOrRevertOnlyMigrationAppStart ||
1546
- this.skipWritingServerRoutes) {
1551
+ if (this.isRemoteHost || this.isRunOrRevertOnlyMigrationAppStart) {
1547
1552
  return;
1548
1553
  }
1549
1554
  // const contexts: EndpointContext[] = [this];
1550
1555
  //#region @websql
1551
- const troutes = lib_9.Utils.uniqArray(this.activeRoutes.map(f => {
1556
+ const troutes = lib_10.Utils.uniqArray(this.activeRoutes.map(f => {
1552
1557
  return `${f.method} ${f.expressPath}`;
1553
1558
  })).map(f => {
1554
1559
  const [method, expressPath] = f.split(' ');
1555
- return (`\n### ${lib_11._.startCase(lib_11._.last(expressPath.split('/')))}\n` +
1560
+ return (`\n### ${lib_12._.startCase(lib_12._.last(expressPath.split('/')))}\n` +
1556
1561
  taon_helpers_1.TaonHelpers.fillUpTo(method.toUpperCase() + ' ', 10) +
1557
1562
  this.uriOrigin +
1558
1563
  expressPath);
@@ -1563,17 +1568,17 @@ class EndpointContext {
1563
1568
  ...['', `# ROUTES FOR HOST ${this.uriOrigin} `],
1564
1569
  ...troutes,
1565
1570
  ].join('\n');
1566
- const fileName = (0, lib_10.crossPlatformPath)([
1571
+ const fileName = (0, lib_11.crossPlatformPath)([
1567
1572
  //#region @backend
1568
1573
  process.cwd(),
1569
1574
  //#endregion
1570
1575
  `routes-${this.config.contextName}.rest`,
1571
1576
  ]);
1572
1577
  this.logFramework && console.log(`[taon] routes file: ${fileName} `);
1573
- // Helpers.log(JSON.stringify(routes, null, 4))
1578
+ this.logRoutes && console.log(routes);
1574
1579
  //#region @backend
1575
- if (!lib_9.UtilsOs.isElectron) {
1576
- lib_11.Helpers.writeFile(fileName, routes);
1580
+ if (!lib_10.UtilsOs.isElectron && !this.skipWritingServerRoutes) {
1581
+ lib_12.Helpers.writeFile(fileName, routes);
1577
1582
  }
1578
1583
  //#endregion
1579
1584
  //#endregion
@@ -1590,7 +1595,7 @@ class EndpointContext {
1590
1595
  async initCustomClientMiddlewares() {
1591
1596
  const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE)
1592
1597
  .map(f => f)
1593
- .filter(f => lib_11._.isFunction(f.interceptClient));
1598
+ .filter(f => lib_12._.isFunction(f.interceptClient));
1594
1599
  middlewares.forEach(middlewareInstanceName => {
1595
1600
  const contextName = this.contextName;
1596
1601
  const interceptorName = `${contextName}-${class_helpers_1.ClassHelpers.getName(middlewareInstanceName)}`;
@@ -1615,7 +1620,7 @@ class EndpointContext {
1615
1620
  const middlewares = this.getClassesInstancesArrBy(models_1.Models.ClassType.MIDDLEWARE);
1616
1621
  for (const middleware of middlewares) {
1617
1622
  const middlewareInstance = middleware;
1618
- if (lib_11._.isFunction(middlewareInstance.interceptServer)) {
1623
+ if (lib_12._.isFunction(middlewareInstance.interceptServer)) {
1619
1624
  const middlewareFn = class_helpers_1.ClassHelpers.asyncHandler(async (req, res, next) => {
1620
1625
  if (req.originalUrl.startsWith(`${this.uriPathnameOrNothingIfRoot}/${constants_1.apiPrefix}/${this.contextName}/`)) {
1621
1626
  await middlewareInstance.interceptServer({
@@ -1651,7 +1656,7 @@ class EndpointContext {
1651
1656
  app.use(methodOverride());
1652
1657
  app.use(cookieParser());
1653
1658
  if (this.session) {
1654
- lib_11.Helpers.info('[taon][express-server] session enabled for this context ' +
1659
+ lib_12.Helpers.info('[taon][express-server] session enabled for this context ' +
1655
1660
  this.contextName);
1656
1661
  const { cookieMaxAge } = this.session;
1657
1662
  const frontendHost = this.config.frontendHost;
@@ -1677,7 +1682,7 @@ class EndpointContext {
1677
1682
  else {
1678
1683
  // if(this.config?.serverLogs) {
1679
1684
  this.logHttp &&
1680
- lib_11.Helpers.info(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
1685
+ lib_12.Helpers.info(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
1681
1686
  // }
1682
1687
  app.use(cors({
1683
1688
  // origin: "http://localhost:5555",
@@ -1734,7 +1739,7 @@ class EndpointContext {
1734
1739
  .map(middlewareClassFun => {
1735
1740
  const middlewareInstance = this.getInstanceBy(middlewareClassFun);
1736
1741
  if (middlewareInstance &&
1737
- lib_11._.isFunction(middlewareInstance.interceptServerMethod)) {
1742
+ lib_12._.isFunction(middlewareInstance.interceptServerMethod)) {
1738
1743
  const middlewareFn = class_helpers_1.ClassHelpers.asyncHandler(async (req, res, next) => {
1739
1744
  await middlewareInstance.interceptServerMethod({
1740
1745
  req,
@@ -1768,7 +1773,7 @@ class EndpointContext {
1768
1773
  //#endregion
1769
1774
  // console.log(`BACKEND: expressPath: "${expressPath}" `);
1770
1775
  //#endregion
1771
- if (lib_11.Helpers.isElectron) {
1776
+ if (lib_12.Helpers.isElectron) {
1772
1777
  //#region @backend
1773
1778
  const ipcKeyName = taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath);
1774
1779
  electron_1.ipcMain.on(ipcKeyName, async (event, paramsFromBrowser) => {
@@ -1786,7 +1791,7 @@ class EndpointContext {
1786
1791
  if (!this.isRemoteHost) {
1787
1792
  //#region apply dummy websql express routers
1788
1793
  //#region @websql
1789
- if (lib_11.Helpers.isWebSQL) {
1794
+ if (lib_12.Helpers.isWebSQL) {
1790
1795
  if (!this.expressApp[httpMethodType.toLowerCase()]) {
1791
1796
  this.expressApp[httpMethodType.toLowerCase()] = () => { };
1792
1797
  // TODO add middlewares for WEBSQL and ELECTRON mode
@@ -1795,8 +1800,8 @@ class EndpointContext {
1795
1800
  //#endregion
1796
1801
  //#endregion
1797
1802
  //#region @backend
1798
- this.logHttp &&
1799
- console.log(`[${httpMethodType.toUpperCase()}] ${expressPath} `);
1803
+ // this.logHttp &&
1804
+ // console.log(`[${httpMethodType.toUpperCase()}] ${expressPath} `);
1800
1805
  this.expressApp[httpMethodType.toLowerCase()](expressPath, ...middlewareHandlers, async (req, res) => {
1801
1806
  // console.log(`[${type.toUpperCase()}] ${expressPath} `);
1802
1807
  //#region process params
@@ -1806,13 +1811,13 @@ class EndpointContext {
1806
1811
  let tQuery = req.query;
1807
1812
  if (req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY]) {
1808
1813
  try {
1809
- tBody = JSON.parse(JSON.stringify(tBody), JSON.parse(req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY]));
1814
+ tBody = JSON.parse(JSON.stringify(tBody), JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY])));
1810
1815
  }
1811
1816
  catch (e) { }
1812
1817
  }
1813
1818
  if (req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM]) {
1814
1819
  try {
1815
- tQuery = JSON.parse(JSON.stringify(tQuery), JSON.parse(req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM]));
1820
+ tQuery = JSON.parse(JSON.stringify(tQuery), JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM])));
1816
1821
  }
1817
1822
  catch (e) { }
1818
1823
  }
@@ -1820,7 +1825,7 @@ class EndpointContext {
1820
1825
  // console.log('req.headers', req.headers)
1821
1826
  if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]) {
1822
1827
  try {
1823
- const entity = JSON.parse(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]);
1828
+ const entity = JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]));
1824
1829
  tBody = lib_3.Mapping.encode(tBody, entity);
1825
1830
  }
1826
1831
  catch (e) { }
@@ -1828,7 +1833,7 @@ class EndpointContext {
1828
1833
  else {
1829
1834
  Object.keys(tBody).forEach(paramName => {
1830
1835
  try {
1831
- const entityForParam = JSON.parse(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${paramName} `]);
1836
+ const entityForParam = JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${paramName} `]));
1832
1837
  tBody[paramName] = lib_3.Mapping.encode(tBody[paramName], entityForParam);
1833
1838
  }
1834
1839
  catch (e) { }
@@ -1838,7 +1843,7 @@ class EndpointContext {
1838
1843
  // console.log('req.headers', tQuery)
1839
1844
  if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]) {
1840
1845
  try {
1841
- const entity = JSON.parse(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]);
1846
+ const entity = JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]));
1842
1847
  tQuery = taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(lib_3.Mapping.encode(tQuery, entity));
1843
1848
  }
1844
1849
  catch (e) { }
@@ -1846,9 +1851,9 @@ class EndpointContext {
1846
1851
  else {
1847
1852
  Object.keys(tQuery).forEach(queryParamName => {
1848
1853
  try {
1849
- const entityForParam = JSON.parse(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${queryParamName} `]);
1854
+ const entityForParam = JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${queryParamName} `]));
1850
1855
  let beforeTransofrm = tQuery[queryParamName];
1851
- if (lib_11._.isString(beforeTransofrm)) {
1856
+ if (lib_12._.isString(beforeTransofrm)) {
1852
1857
  try {
1853
1858
  const paresed = taon_helpers_1.TaonHelpers.tryTransformParam(beforeTransofrm);
1854
1859
  beforeTransofrm = paresed;
@@ -1896,6 +1901,16 @@ class EndpointContext {
1896
1901
  .map(v => taon_helpers_1.TaonHelpers.tryTransformParam(v));
1897
1902
  try {
1898
1903
  let result = await getResult(resolvedParams, req, res);
1904
+ if (methodConfig.responseType)
1905
+ if (res.headersSent) {
1906
+ // SKIP FURTHER PROCESSING IF RESPONSE ALREADY SENT
1907
+ return;
1908
+ }
1909
+ if (methodConfig.overrideExpressSendAsHtml) {
1910
+ res.setHeader('Content-Type', 'text/html');
1911
+ res.send(result);
1912
+ return;
1913
+ }
1899
1914
  if (result instanceof Blob &&
1900
1915
  methodConfig.responseType ===
1901
1916
  'blob') {
@@ -1910,7 +1925,7 @@ class EndpointContext {
1910
1925
  res.end(file);
1911
1926
  //#endregion
1912
1927
  }
1913
- else if (lib_11._.isString(result) &&
1928
+ else if (lib_12._.isString(result) &&
1914
1929
  methodConfig.responseType ===
1915
1930
  'blob') {
1916
1931
  // console.log('BASE64')
@@ -1936,36 +1951,16 @@ class EndpointContext {
1936
1951
  }
1937
1952
  }
1938
1953
  catch (error) {
1939
- //#region process error
1940
- if (lib_11._.isString(error)) {
1941
- res.status(400).send(lib_1.JSON10.stringify({
1942
- message: `
1943
- Error inside: ${req.path}
1944
-
1945
- ${error}
1946
-
1947
- `,
1948
- }));
1949
- }
1950
- else if (error instanceof models_1.Models.Http.Errors) {
1951
- lib_11.Helpers.error(error, true, false);
1952
- const err = error;
1953
- res.status(400).send(lib_1.JSON10.stringify(err));
1954
+ if (res.headersSent) {
1955
+ // SKIP FURTHER PROCESSING IF RESPONSE ALREADY SENT
1956
+ return;
1954
1957
  }
1955
- else if (error instanceof Error) {
1956
- const err = error;
1957
- lib_11.Helpers.error(error, true, false);
1958
- res.status(400).send(lib_1.JSON10.stringify({
1959
- stack: err.stack,
1960
- message: err.message,
1961
- }));
1958
+ if (methodConfig.overrideExpressSendAsHtml) {
1959
+ res.setHeader('Content-Type', 'text/html');
1960
+ res.send(error);
1961
+ return;
1962
1962
  }
1963
- else {
1964
- lib_11.Helpers.log(error);
1965
- lib_11.Helpers.error(`[Taon] Bad result isomorphic method: ${error} `, true, false);
1966
- res.status(400).send(lib_1.JSON10.stringify(error));
1967
- }
1968
- //#endregion
1963
+ this.sendError(res, error, req, expressPath);
1969
1964
  }
1970
1965
  });
1971
1966
  //#endregion
@@ -1976,6 +1971,41 @@ class EndpointContext {
1976
1971
  };
1977
1972
  }
1978
1973
  //#endregion
1974
+ sendError(res, error, req, expressPath) {
1975
+ //#region @backendFunc
1976
+ let status = 500;
1977
+ let message = 'Internal Server Error';
1978
+ let details = undefined;
1979
+ let success = false;
1980
+ let code = undefined;
1981
+ if (typeof error === 'function') {
1982
+ const obj = error(res) || {};
1983
+ status = obj.status || 400;
1984
+ message = obj.message;
1985
+ details = obj.details;
1986
+ code = obj.code;
1987
+ }
1988
+ else if (typeof error === 'string') {
1989
+ message = error;
1990
+ status = 400;
1991
+ }
1992
+ else if (error instanceof Error) {
1993
+ message = error.message;
1994
+ details = process.env.NODE_ENV !== 'production' ? error.stack : undefined;
1995
+ }
1996
+ else {
1997
+ message = 'Unexpected error';
1998
+ details = error;
1999
+ }
2000
+ res.status(status).json({
2001
+ success,
2002
+ message,
2003
+ details,
2004
+ code,
2005
+ [lib_8.CoreModels.TaonHttpErrorCustomProp]: true,
2006
+ });
2007
+ //#endregion
2008
+ }
1979
2009
  //#region methods & getters / init client
1980
2010
  /**
1981
2011
  * client can be browser or nodejs (when remote host)
@@ -1990,7 +2020,7 @@ class EndpointContext {
1990
2020
  const middlewares = methodConfig.calculatedMiddlewares;
1991
2021
  const middlewaresInstances = middlewares
1992
2022
  .map(f => this.getInstanceBy(f))
1993
- .filter(f => lib_11._.isFunction(f.interceptClientMethod));
2023
+ .filter(f => lib_12._.isFunction(f.interceptClientMethod));
1994
2024
  middlewaresInstances.forEach(instance => {
1995
2025
  const middlewareName = class_helpers_1.ClassHelpers.getName(instance);
1996
2026
  // middlewareName - only needed for inheritace and uniqness of interceptors
@@ -2010,8 +2040,8 @@ class EndpointContext {
2010
2040
  });
2011
2041
  //#endregion
2012
2042
  // : { received: any; /* Rest<any, any> */ }
2013
- this.logHttp &&
2014
- console.log(`${httpRequestType?.toUpperCase()} ${expressPath} `);
2043
+ // this.logHttp &&
2044
+ // console.log(`${httpRequestType?.toUpperCase()} ${expressPath} `);
2015
2045
  // console.log('INITING', methodConfig); // TODO inject in static
2016
2046
  //#region resolve storage
2017
2047
  // TODO not a good idea
@@ -2019,7 +2049,7 @@ class EndpointContext {
2019
2049
  //#endregion
2020
2050
  const orgMethods = target.prototype[methodConfig.methodName];
2021
2051
  //#region handle electron ipc request
2022
- if (lib_11.Helpers.isElectron) {
2052
+ if (lib_12.Helpers.isElectron) {
2023
2053
  const ipcRenderer = window.require('electron').ipcRenderer;
2024
2054
  target.prototype[methodConfig.methodName] = function (...args) {
2025
2055
  const received = new Promise(async (resolve, reject) => {
@@ -2302,7 +2332,7 @@ class EndpointContext {
2302
2332
  if (mapping) {
2303
2333
  rest.headers.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
2304
2334
  }
2305
- queryParams = lib_11._.cloneDeep(param);
2335
+ queryParams = lib_12._.cloneDeep(param);
2306
2336
  }
2307
2337
  }
2308
2338
  if (currentParam.paramType === 'Header') {