@opra/nestjs 1.0.0-alpha.20 → 1.0.0-alpha.21
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.
|
@@ -66,7 +66,7 @@ class OpraNestAdapter extends core_1.HttpAdapter {
|
|
|
66
66
|
/** Copy metadata keys from source class to new one */
|
|
67
67
|
let metadataKeys;
|
|
68
68
|
if (parentClass) {
|
|
69
|
-
OpraNestAdapter.copyDecoratorMetadataToChild(newClass,
|
|
69
|
+
OpraNestAdapter.copyDecoratorMetadataToChild(newClass, parentClass);
|
|
70
70
|
}
|
|
71
71
|
const newPath = metadata.path ? path_1.default.join(currentPath, metadata.path) : currentPath;
|
|
72
72
|
const adapter = this;
|
|
@@ -162,15 +162,19 @@ class OpraNestAdapter extends core_1.HttpAdapter {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
static copyDecoratorMetadataToChild(target,
|
|
165
|
+
static copyDecoratorMetadataToChild(target, parent) {
|
|
166
166
|
const metadataKeys = Reflect.getOwnMetadataKeys(parent);
|
|
167
167
|
for (const key of metadataKeys) {
|
|
168
168
|
if (key === constants_1.GUARDS_METADATA || key === constants_1.INTERCEPTORS_METADATA || key === constants_1.EXCEPTION_FILTERS_METADATA) {
|
|
169
|
-
const m1 = Reflect.getMetadata(key,
|
|
170
|
-
const m2 = Reflect.
|
|
169
|
+
const m1 = Reflect.getMetadata(key, target) || [];
|
|
170
|
+
const m2 = Reflect.getOwnMetadata(key, parent) || [];
|
|
171
171
|
Reflect.defineMetadata(key, [...m1, ...m2], target);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
+
const subParent = Object.getPrototypeOf(parent.prototype).constructor;
|
|
175
|
+
if (subParent && subParent !== Object) {
|
|
176
|
+
this.copyDecoratorMetadataToChild(target, subParent);
|
|
177
|
+
}
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
exports.OpraNestAdapter = OpraNestAdapter;
|
|
@@ -63,7 +63,7 @@ export class OpraNestAdapter extends HttpAdapter {
|
|
|
63
63
|
/** Copy metadata keys from source class to new one */
|
|
64
64
|
let metadataKeys;
|
|
65
65
|
if (parentClass) {
|
|
66
|
-
OpraNestAdapter.copyDecoratorMetadataToChild(newClass,
|
|
66
|
+
OpraNestAdapter.copyDecoratorMetadataToChild(newClass, parentClass);
|
|
67
67
|
}
|
|
68
68
|
const newPath = metadata.path ? nodePath.join(currentPath, metadata.path) : currentPath;
|
|
69
69
|
const adapter = this;
|
|
@@ -159,14 +159,18 @@ export class OpraNestAdapter extends HttpAdapter {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
static copyDecoratorMetadataToChild(target,
|
|
162
|
+
static copyDecoratorMetadataToChild(target, parent) {
|
|
163
163
|
const metadataKeys = Reflect.getOwnMetadataKeys(parent);
|
|
164
164
|
for (const key of metadataKeys) {
|
|
165
165
|
if (key === GUARDS_METADATA || key === INTERCEPTORS_METADATA || key === EXCEPTION_FILTERS_METADATA) {
|
|
166
|
-
const m1 = Reflect.getMetadata(key,
|
|
167
|
-
const m2 = Reflect.
|
|
166
|
+
const m1 = Reflect.getMetadata(key, target) || [];
|
|
167
|
+
const m2 = Reflect.getOwnMetadata(key, parent) || [];
|
|
168
168
|
Reflect.defineMetadata(key, [...m1, ...m2], target);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
+
const subParent = Object.getPrototypeOf(parent.prototype).constructor;
|
|
172
|
+
if (subParent && subParent !== Object) {
|
|
173
|
+
this.copyDecoratorMetadataToChild(target, subParent);
|
|
174
|
+
}
|
|
171
175
|
}
|
|
172
176
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/nestjs",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.21",
|
|
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.
|
|
31
|
-
"@opra/core": "^1.0.0-alpha.
|
|
30
|
+
"@opra/common": "^1.0.0-alpha.21",
|
|
31
|
+
"@opra/core": "^1.0.0-alpha.21",
|
|
32
32
|
"fast-tokenizer": "^1.3.0",
|
|
33
33
|
"lodash.head": "^4.0.1",
|
|
34
34
|
"reflect-metadata": "^0.2.2"
|
|
@@ -9,5 +9,5 @@ export declare class OpraNestAdapter extends HttpAdapter {
|
|
|
9
9
|
close(): Promise<void>;
|
|
10
10
|
protected _addRootController(basePath: string): void;
|
|
11
11
|
protected _addToNestControllers(sourceClass: Type, currentPath: string, parentClass?: Type): void;
|
|
12
|
-
static copyDecoratorMetadataToChild(target: Type,
|
|
12
|
+
static copyDecoratorMetadataToChild(target: Type, parent: Type): void;
|
|
13
13
|
}
|