@tsed/common 6.75.8 → 6.75.12

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.
@@ -1,3 +1,6 @@
1
+ import { $log, colorize } from '@tsed/logger';
2
+ export { $log, Logger } from '@tsed/logger';
3
+ import '@tsed/logger-file';
1
4
  import { DIConfiguration, ProviderType, ProviderScope, Injectable, Inject, InjectorService, Constant, Scope, DIContext, Provider, setLoggerLevel, GlobalProviders, registerProvider, Configuration, createContainer, Container, getConfiguration, DITest } from '@tsed/di';
2
5
  export * from '@tsed/di';
3
6
  import { ParamTypes, ParamMetadata, PlatformParams, Context, UseParam, mapParamsOptions } from '@tsed/platform-params';
@@ -13,10 +16,8 @@ export * from '@tsed/platform-views';
13
16
  import { importProviders } from '@tsed/components-scan';
14
17
  export * from '@tsed/components-scan';
15
18
  export * from '@tsed/platform-log-middleware';
16
- import { $log, colorize } from '@tsed/logger';
17
- export { $log, Logger } from '@tsed/logger';
18
19
  import { __decorate, __metadata, __param } from 'tslib';
19
- import { Env, AnyToPromise, AnyToPromiseStatus, nameOf, Store, descriptorOf, classOf, prototypeOf, deepMerge, isFunction, DecoratorTypes, isStream, uniq, isBoolean, isNumber, isString, getValue, toMap, constructorOf, StoreMerge, Metadata, useDecorators, useMethodDecorators, isClass } from '@tsed/core';
20
+ import { Env, AnyToPromise, AnyToPromiseStatus, nameOf, Store, descriptorOf, classOf, prototypeOf, deepMerge, isFunction, DecoratorTypes, isStream, uniq, isBoolean, isNumber, isString, getValue, toMap, StoreMerge, Metadata, useDecorators, useMethodDecorators, isClass } from '@tsed/core';
20
21
  import { PerfLogger } from '@tsed/perf';
21
22
  import { Exception, NotAcceptable } from '@tsed/exceptions';
22
23
  import { JsonEntityStore, getOperationsStores, JsonEntityComponent, OperationMethods, getProperties, Returns, Consumes, JsonEntityFn, Produces } from '@tsed/schema';
@@ -1556,7 +1557,7 @@ let PlatformRequest = class PlatformRequest {
1556
1557
  }
1557
1558
 
1558
1559
  get rawBody() {
1559
- return this.raw.rawBody;
1560
+ return this.raw.rawBody || this.raw.body;
1560
1561
  }
1561
1562
  /**
1562
1563
  * When using `cookie-parser` middleware, this property is an object that contains cookies sent by the request.
@@ -2670,7 +2671,6 @@ function getStaticsOptions(statics) {
2670
2671
  }, []);
2671
2672
  }
2672
2673
 
2673
- const SKIP_HOOKS = ["$beforeInit", "$afterInit", "$onInit", "$onMountingMiddlewares"];
2674
2674
  const {
2675
2675
  bind,
2676
2676
  start,
@@ -2681,26 +2681,26 @@ const {
2681
2681
  * @platform
2682
2682
  */
2683
2683
 
2684
- var _rootModule = /*#__PURE__*/_classPrivateFieldLooseKey("rootModule");
2685
-
2686
2684
  var _injector = /*#__PURE__*/_classPrivateFieldLooseKey("injector");
2687
2685
 
2688
2686
  var _providers = /*#__PURE__*/_classPrivateFieldLooseKey("providers");
2689
2687
 
2688
+ var _rootModule = /*#__PURE__*/_classPrivateFieldLooseKey("rootModule");
2689
+
2690
2690
  class PlatformBuilder {
2691
2691
  constructor({
2692
2692
  name,
2693
2693
  providers
2694
2694
  }) {
2695
- Object.defineProperty(this, _rootModule, {
2695
+ Object.defineProperty(this, _injector, {
2696
2696
  writable: true,
2697
2697
  value: void 0
2698
2698
  });
2699
- Object.defineProperty(this, _injector, {
2699
+ Object.defineProperty(this, _providers, {
2700
2700
  writable: true,
2701
2701
  value: void 0
2702
2702
  });
2703
- Object.defineProperty(this, _providers, {
2703
+ Object.defineProperty(this, _rootModule, {
2704
2704
  writable: true,
2705
2705
  value: void 0
2706
2706
  });
@@ -2717,7 +2717,7 @@ class PlatformBuilder {
2717
2717
  }
2718
2718
 
2719
2719
  get rootModule() {
2720
- return _classPrivateFieldLooseBase(this, _rootModule)[_rootModule];
2720
+ return _classPrivateFieldLooseBase(this, _injector)[_injector].get(_classPrivateFieldLooseBase(this, _rootModule)[_rootModule]);
2721
2721
  }
2722
2722
 
2723
2723
  get app() {
@@ -2824,9 +2824,12 @@ class PlatformBuilder {
2824
2824
  const {
2825
2825
  injector
2826
2826
  } = this;
2827
- await this.callHook("$beforeInit");
2828
2827
  this.log("Build providers");
2829
- const container = createContainer(constructorOf(this.rootModule));
2828
+ const container = createContainer();
2829
+ container.addProvider(_classPrivateFieldLooseBase(this, _rootModule)[_rootModule], {
2830
+ type: "server:module",
2831
+ scope: ProviderScope.SINGLETON
2832
+ });
2830
2833
  await injector.load(container);
2831
2834
  this.log("Settings and injector loaded");
2832
2835
  await this.callHook("$afterInit");
@@ -2856,26 +2859,18 @@ class PlatformBuilder {
2856
2859
 
2857
2860
  async callHook(hook, ...args) {
2858
2861
  const {
2859
- injector,
2860
- rootModule
2862
+ injector
2861
2863
  } = this;
2862
2864
  log(hook);
2863
2865
 
2864
2866
  if (!this.disableBootstrapLog) {
2865
2867
  injector.logger.info(`\x1B[1mCall hook ${hook}\x1B[22m`);
2866
- } // call hook for the Server
2867
-
2868
-
2869
- if (hook in rootModule) {
2870
- await rootModule[hook](...args);
2871
2868
  } // Load middlewares for the given hook
2872
2869
 
2873
2870
 
2874
2871
  this.loadMiddlewaresFor(hook); // call hooks added by providers
2875
2872
 
2876
- if (!SKIP_HOOKS.includes(hook)) {
2877
- await injector.emit(hook);
2878
- }
2873
+ await injector.emit(hook);
2879
2874
  }
2880
2875
 
2881
2876
  async loadStatics(hook) {
@@ -2945,7 +2940,6 @@ class PlatformBuilder {
2945
2940
  this.createInjector(module, _extends({}, settings, {
2946
2941
  PLATFORM_NAME: this.name
2947
2942
  }));
2948
- this.createRootModule(module);
2949
2943
  await this.runLifecycle();
2950
2944
  return this;
2951
2945
  }
@@ -2994,6 +2988,7 @@ class PlatformBuilder {
2994
2988
  }
2995
2989
 
2996
2990
  createInjector(module, settings) {
2991
+ _classPrivateFieldLooseBase(this, _rootModule)[_rootModule] = module;
2997
2992
  const configuration = getConfiguration(module, settings);
2998
2993
  _classPrivateFieldLooseBase(this, _injector)[_injector] = createInjector(configuration); // configure locals providers
2999
2994
 
@@ -3005,12 +3000,6 @@ class PlatformBuilder {
3005
3000
  createHttpServer(this.injector);
3006
3001
  }
3007
3002
 
3008
- createRootModule(module) {
3009
- _classPrivateFieldLooseBase(this, _rootModule)[_rootModule] = this.injector.invoke(module);
3010
- this.injector.delete(constructorOf(_classPrivateFieldLooseBase(this, _rootModule)[_rootModule]));
3011
- this.injector.delete(classOf(_classPrivateFieldLooseBase(this, _rootModule)[_rootModule]));
3012
- }
3013
-
3014
3003
  }
3015
3004
 
3016
3005
  /**