@opra/nestjs 1.0.0-alpha.16 → 1.0.0-alpha.17

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.
@@ -54,7 +54,7 @@ class OpraNestAdapter extends core_1.HttpAdapter {
54
54
  }
55
55
  this.nestControllers.push(RootController);
56
56
  }
57
- _addToNestControllers(sourceClass, currentPath) {
57
+ _addToNestControllers(sourceClass, currentPath, parentClass) {
58
58
  const metadata = Reflect.getMetadata(common_2.HTTP_CONTROLLER_METADATA, sourceClass);
59
59
  if (!metadata)
60
60
  return;
@@ -62,6 +62,15 @@ class OpraNestAdapter extends core_1.HttpAdapter {
62
62
  [sourceClass.name]: class extends sourceClass {
63
63
  },
64
64
  }[sourceClass.name];
65
+ /** Copy metadata keys from source class to new one */
66
+ let metadataKeys;
67
+ if (parentClass) {
68
+ metadataKeys = Reflect.getOwnMetadataKeys(parentClass);
69
+ for (const key of metadataKeys) {
70
+ const m = Reflect.getMetadata(key, parentClass);
71
+ Reflect.defineMetadata(key, m, newClass);
72
+ }
73
+ }
65
74
  const newPath = metadata.path ? path_1.default.join(currentPath, metadata.path) : currentPath;
66
75
  const adapter = this;
67
76
  /** Inject exception filter */
@@ -100,7 +109,7 @@ class OpraNestAdapter extends core_1.HttpAdapter {
100
109
  },
101
110
  });
102
111
  /** Copy metadata keys from source function to new one */
103
- const metadataKeys = Reflect.getOwnMetadataKeys(operationHandler);
112
+ metadataKeys = Reflect.getOwnMetadataKeys(operationHandler);
104
113
  const newFn = newClass.prototype[k];
105
114
  for (const key of metadataKeys) {
106
115
  const m = Reflect.getMetadata(key, operationHandler);
@@ -152,7 +161,7 @@ class OpraNestAdapter extends core_1.HttpAdapter {
152
161
  for (const child of metadata.controllers) {
153
162
  if (!(0, common_2.isConstructor)(child))
154
163
  throw new TypeError('Controllers should be injectable a class');
155
- this._addToNestControllers(child, newPath);
164
+ this._addToNestControllers(child, newPath, sourceClass);
156
165
  }
157
166
  }
158
167
  }
@@ -51,7 +51,7 @@ export class OpraNestAdapter extends HttpAdapter {
51
51
  }
52
52
  this.nestControllers.push(RootController);
53
53
  }
54
- _addToNestControllers(sourceClass, currentPath) {
54
+ _addToNestControllers(sourceClass, currentPath, parentClass) {
55
55
  const metadata = Reflect.getMetadata(HTTP_CONTROLLER_METADATA, sourceClass);
56
56
  if (!metadata)
57
57
  return;
@@ -59,6 +59,15 @@ export class OpraNestAdapter extends HttpAdapter {
59
59
  [sourceClass.name]: class extends sourceClass {
60
60
  },
61
61
  }[sourceClass.name];
62
+ /** Copy metadata keys from source class to new one */
63
+ let metadataKeys;
64
+ if (parentClass) {
65
+ metadataKeys = Reflect.getOwnMetadataKeys(parentClass);
66
+ for (const key of metadataKeys) {
67
+ const m = Reflect.getMetadata(key, parentClass);
68
+ Reflect.defineMetadata(key, m, newClass);
69
+ }
70
+ }
62
71
  const newPath = metadata.path ? nodePath.join(currentPath, metadata.path) : currentPath;
63
72
  const adapter = this;
64
73
  /** Inject exception filter */
@@ -97,7 +106,7 @@ export class OpraNestAdapter extends HttpAdapter {
97
106
  },
98
107
  });
99
108
  /** Copy metadata keys from source function to new one */
100
- const metadataKeys = Reflect.getOwnMetadataKeys(operationHandler);
109
+ metadataKeys = Reflect.getOwnMetadataKeys(operationHandler);
101
110
  const newFn = newClass.prototype[k];
102
111
  for (const key of metadataKeys) {
103
112
  const m = Reflect.getMetadata(key, operationHandler);
@@ -149,7 +158,7 @@ export class OpraNestAdapter extends HttpAdapter {
149
158
  for (const child of metadata.controllers) {
150
159
  if (!isConstructor(child))
151
160
  throw new TypeError('Controllers should be injectable a class');
152
- this._addToNestControllers(child, newPath);
161
+ this._addToNestControllers(child, newPath, sourceClass);
153
162
  }
154
163
  }
155
164
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/nestjs",
3
- "version": "1.0.0-alpha.16",
3
+ "version": "1.0.0-alpha.17",
4
4
  "description": "Opra NestJS module",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -27,8 +27,8 @@
27
27
  "clean:cover": "rimraf ../../coverage/client"
28
28
  },
29
29
  "dependencies": {
30
- "@opra/common": "^1.0.0-alpha.16",
31
- "@opra/core": "^1.0.0-alpha.16",
30
+ "@opra/common": "^1.0.0-alpha.17",
31
+ "@opra/core": "^1.0.0-alpha.17",
32
32
  "fast-tokenizer": "^1.3.0",
33
33
  "lodash.head": "^4.0.1",
34
34
  "reflect-metadata": "^0.2.2"
@@ -8,5 +8,5 @@ export declare class OpraNestAdapter extends HttpAdapter {
8
8
  constructor(init: OpraHttpModule.Initiator, options?: OpraHttpModule.Options);
9
9
  close(): Promise<void>;
10
10
  protected _addRootController(basePath: string): void;
11
- protected _addToNestControllers(sourceClass: Type, currentPath: string): void;
11
+ protected _addToNestControllers(sourceClass: Type, currentPath: string, parentClass?: Type): void;
12
12
  }