moost 0.2.2 → 0.2.4

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/dist/index.cjs CHANGED
@@ -178,7 +178,7 @@ var EHttpStatusCode;
178
178
  DELETE: EHttpStatusCode.Accepted,
179
179
  });
180
180
 
181
- class WooksError extends Error {
181
+ class HttpError extends Error {
182
182
  constructor(code = 500, _body = '') {
183
183
  super(typeof _body === 'string' ? _body : _body.message);
184
184
  this.code = code;
@@ -660,6 +660,15 @@ class Moost {
660
660
  init() {
661
661
  return __awaiter(this, void 0, void 0, function* () {
662
662
  this.setProvideRegistry(infact.createProvideRegistry([Moost, () => this]));
663
+ for (const a of this.adapters) {
664
+ const constructor = mate.getConstructor(a);
665
+ if (constructor) {
666
+ this.setProvideRegistry(infact.createProvideRegistry([constructor, () => a]));
667
+ }
668
+ if (typeof a.getProvideRegistry === 'function') {
669
+ this.setProvideRegistry(a.getProvideRegistry());
670
+ }
671
+ }
663
672
  this.unregisteredControllers.unshift(this);
664
673
  yield this.bindControllers();
665
674
  for (const a of this.adapters) {
@@ -687,7 +696,7 @@ class Moost {
687
696
  const infact = getMoostInfact();
688
697
  const isControllerConsructor = mate.isConstructor(controller);
689
698
  let instance;
690
- if (isControllerConsructor && (classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === 'SINGLETON') {
699
+ if (isControllerConsructor && ((classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === 'SINGLETON' || (classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === true)) {
691
700
  instance = (yield infact.get(controller, provide));
692
701
  }
693
702
  else if (!isControllerConsructor) {
@@ -850,7 +859,7 @@ const genericTypesCastPipe = (strict) => {
850
859
  };
851
860
  function typeError(value, targetType, label) {
852
861
  const prefix = label ? `Argument "${label}" with value ` : '';
853
- throw new WooksError(400, `${prefix}${JSON.stringify(value)} is not a ${targetType} type`);
862
+ throw new HttpError(400, `${prefix}${JSON.stringify(value)} is not a ${targetType} type`);
854
863
  }
855
864
 
856
865
  const DEFAULT_ERROR_LIMIT = 10;
@@ -869,7 +878,7 @@ const validatePipe = (opts) => {
869
878
  const valido = getMoostValido();
870
879
  const result = yield valido.validateParam(_value, meta, undefined, undefined, undefined, undefined, 0, 0, (opts === null || opts === void 0 ? void 0 : opts.errorLimit) || DEFAULT_ERROR_LIMIT, restoreCtx);
871
880
  if (result !== true) {
872
- throw new WooksError(400, {
881
+ throw new HttpError(400, {
873
882
  statusCode: 400,
874
883
  message: typeof result === 'string' ? result : firstString(result),
875
884
  error: 'Validation Error',
package/dist/index.d.ts CHANGED
@@ -215,6 +215,7 @@ export declare enum TInterceptorPriority {
215
215
  export declare interface TMoostAdapter<H extends object> {
216
216
  bindHandler<T extends TObject = TObject>(options: TMoostAdapterOptions<H, T>): void | Promise<void>;
217
217
  onInit?: () => void | Promise<void>;
218
+ getProvideRegistry?: () => TProvideRegistry;
218
219
  }
219
220
 
220
221
  export declare interface TMoostAdapterOptions<H extends object, T extends object> {
package/dist/index.mjs CHANGED
@@ -176,7 +176,7 @@ var EHttpStatusCode;
176
176
  DELETE: EHttpStatusCode.Accepted,
177
177
  });
178
178
 
179
- class WooksError extends Error {
179
+ class HttpError extends Error {
180
180
  constructor(code = 500, _body = '') {
181
181
  super(typeof _body === 'string' ? _body : _body.message);
182
182
  this.code = code;
@@ -658,6 +658,15 @@ class Moost {
658
658
  init() {
659
659
  return __awaiter(this, void 0, void 0, function* () {
660
660
  this.setProvideRegistry(createProvideRegistry([Moost, () => this]));
661
+ for (const a of this.adapters) {
662
+ const constructor = getConstructor(a);
663
+ if (constructor) {
664
+ this.setProvideRegistry(createProvideRegistry([constructor, () => a]));
665
+ }
666
+ if (typeof a.getProvideRegistry === 'function') {
667
+ this.setProvideRegistry(a.getProvideRegistry());
668
+ }
669
+ }
661
670
  this.unregisteredControllers.unshift(this);
662
671
  yield this.bindControllers();
663
672
  for (const a of this.adapters) {
@@ -685,7 +694,7 @@ class Moost {
685
694
  const infact = getMoostInfact();
686
695
  const isControllerConsructor = isConstructor(controller);
687
696
  let instance;
688
- if (isControllerConsructor && (classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === 'SINGLETON') {
697
+ if (isControllerConsructor && ((classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === 'SINGLETON' || (classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === true)) {
689
698
  instance = (yield infact.get(controller, provide));
690
699
  }
691
700
  else if (!isControllerConsructor) {
@@ -848,7 +857,7 @@ const genericTypesCastPipe = (strict) => {
848
857
  };
849
858
  function typeError(value, targetType, label) {
850
859
  const prefix = label ? `Argument "${label}" with value ` : '';
851
- throw new WooksError(400, `${prefix}${JSON.stringify(value)} is not a ${targetType} type`);
860
+ throw new HttpError(400, `${prefix}${JSON.stringify(value)} is not a ${targetType} type`);
852
861
  }
853
862
 
854
863
  const DEFAULT_ERROR_LIMIT = 10;
@@ -867,7 +876,7 @@ const validatePipe = (opts) => {
867
876
  const valido = getMoostValido();
868
877
  const result = yield valido.validateParam(_value, meta, undefined, undefined, undefined, undefined, 0, 0, (opts === null || opts === void 0 ? void 0 : opts.errorLimit) || DEFAULT_ERROR_LIMIT, restoreCtx);
869
878
  if (result !== true) {
870
- throw new WooksError(400, {
879
+ throw new HttpError(400, {
871
880
  statusCode: 400,
872
881
  message: typeof result === 'string' ? result : firstString(result),
873
882
  error: 'Validation Error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moost",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "moost",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -25,8 +25,8 @@
25
25
  "@prostojs/infact": "^0.0.13",
26
26
  "@prostojs/mate": "^0.1.10",
27
27
  "@prostojs/valido": "^0.0.2",
28
- "@wooksjs/event-core": "^0.2.4",
29
- "wooks": "^0.2.4"
28
+ "@wooksjs/event-core": "^0.2.5",
29
+ "wooks": "^0.2.5"
30
30
  },
31
31
  "author": "Artem Maltsev",
32
32
  "license": "MIT",