@opra/nestjs 0.24.0 → 0.24.1
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.
|
@@ -37,21 +37,22 @@ let OpraApiFactory = exports.OpraApiFactory = class OpraApiFactory {
|
|
|
37
37
|
for (const wrapper of wrappers) {
|
|
38
38
|
const instance = wrapper.instance;
|
|
39
39
|
const ctor = instance.constructor;
|
|
40
|
-
const metadata = Reflect.getMetadata(common_2.
|
|
40
|
+
const metadata = Reflect.getMetadata(common_2.RESOURCE_METADATA, ctor);
|
|
41
41
|
if (common_2.OpraSchema.isSource(metadata))
|
|
42
42
|
resources.push(instance);
|
|
43
43
|
}
|
|
44
44
|
for (const wrapper of wrappers) {
|
|
45
45
|
const instance = wrapper.instance;
|
|
46
46
|
const ctor = instance.constructor;
|
|
47
|
-
const sourceDef = Reflect.getMetadata(common_2.
|
|
47
|
+
const sourceDef = Reflect.getMetadata(common_2.RESOURCE_METADATA, ctor);
|
|
48
48
|
/* istanbul ignore next */
|
|
49
49
|
if (!sourceDef)
|
|
50
50
|
continue;
|
|
51
51
|
resources.push(instance);
|
|
52
52
|
/* Wrap resolver functions */
|
|
53
53
|
const isRequestScoped = !wrapper.isDependencyTreeStatic();
|
|
54
|
-
if (
|
|
54
|
+
if (sourceDef.operations &&
|
|
55
|
+
(common_2.OpraSchema.isCollection(sourceDef) || common_2.OpraSchema.isSingleton(sourceDef) || common_2.OpraSchema.isStorage(sourceDef))) {
|
|
55
56
|
for (const methodName of Object.keys(sourceDef.operations)) {
|
|
56
57
|
const endpointFunction = instance[methodName];
|
|
57
58
|
const nestHandlerName = methodName + '_nestjs';
|
|
@@ -28,7 +28,7 @@ class NestExplorer {
|
|
|
28
28
|
return !!(wrapper.instance
|
|
29
29
|
&& typeof wrapper.instance === 'object'
|
|
30
30
|
&& wrapper.instance.constructor
|
|
31
|
-
&& common_1.OpraSchema.isSource(Reflect.getMetadata(common_1.
|
|
31
|
+
&& common_1.OpraSchema.isSource(Reflect.getMetadata(common_1.RESOURCE_METADATA, wrapper.instance.constructor)));
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -5,7 +5,7 @@ import { ContextIdFactory, createContextId, REQUEST } from '@nestjs/core';
|
|
|
5
5
|
import { Injector } from '@nestjs/core/injector/injector';
|
|
6
6
|
import { InternalCoreModule } from '@nestjs/core/injector/internal-core-module';
|
|
7
7
|
import { REQUEST_CONTEXT_ID } from '@nestjs/core/router/request/request-constants';
|
|
8
|
-
import { DocumentFactory, OpraSchema,
|
|
8
|
+
import { DocumentFactory, OpraSchema, RESOURCE_METADATA } from '@opra/common';
|
|
9
9
|
import { PARAM_ARGS_METADATA } from '../constants.js';
|
|
10
10
|
import { HandlerParamType } from '../enums/handler-paramtype.enum.js';
|
|
11
11
|
import { getNumberOfArguments } from '../utils/function.utils.js';
|
|
@@ -34,21 +34,22 @@ export let OpraApiFactory = class OpraApiFactory {
|
|
|
34
34
|
for (const wrapper of wrappers) {
|
|
35
35
|
const instance = wrapper.instance;
|
|
36
36
|
const ctor = instance.constructor;
|
|
37
|
-
const metadata = Reflect.getMetadata(
|
|
37
|
+
const metadata = Reflect.getMetadata(RESOURCE_METADATA, ctor);
|
|
38
38
|
if (OpraSchema.isSource(metadata))
|
|
39
39
|
resources.push(instance);
|
|
40
40
|
}
|
|
41
41
|
for (const wrapper of wrappers) {
|
|
42
42
|
const instance = wrapper.instance;
|
|
43
43
|
const ctor = instance.constructor;
|
|
44
|
-
const sourceDef = Reflect.getMetadata(
|
|
44
|
+
const sourceDef = Reflect.getMetadata(RESOURCE_METADATA, ctor);
|
|
45
45
|
/* istanbul ignore next */
|
|
46
46
|
if (!sourceDef)
|
|
47
47
|
continue;
|
|
48
48
|
resources.push(instance);
|
|
49
49
|
/* Wrap resolver functions */
|
|
50
50
|
const isRequestScoped = !wrapper.isDependencyTreeStatic();
|
|
51
|
-
if (
|
|
51
|
+
if (sourceDef.operations &&
|
|
52
|
+
(OpraSchema.isCollection(sourceDef) || OpraSchema.isSingleton(sourceDef) || OpraSchema.isStorage(sourceDef))) {
|
|
52
53
|
for (const methodName of Object.keys(sourceDef.operations)) {
|
|
53
54
|
const endpointFunction = instance[methodName];
|
|
54
55
|
const nestHandlerName = methodName + '_nestjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OpraSchema,
|
|
1
|
+
import { OpraSchema, RESOURCE_METADATA } from '@opra/common';
|
|
2
2
|
export class NestExplorer {
|
|
3
3
|
exploreProviders(rootModule, predicate) {
|
|
4
4
|
const modules = new Set();
|
|
@@ -25,7 +25,7 @@ export class NestExplorer {
|
|
|
25
25
|
return !!(wrapper.instance
|
|
26
26
|
&& typeof wrapper.instance === 'object'
|
|
27
27
|
&& wrapper.instance.constructor
|
|
28
|
-
&& OpraSchema.isSource(Reflect.getMetadata(
|
|
28
|
+
&& OpraSchema.isSource(Reflect.getMetadata(RESOURCE_METADATA, wrapper.instance.constructor)));
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/nestjs",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "Opra NestJS module",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"clean:cover": "rimraf ../../coverage/nestjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@opra/common": "^0.24.
|
|
29
|
-
"@opra/core": "^0.24.
|
|
28
|
+
"@opra/common": "^0.24.1",
|
|
29
|
+
"@opra/core": "^0.24.1",
|
|
30
30
|
"fast-tokenizer": "^1.2.2",
|
|
31
31
|
"lodash.head": "^4.0.1",
|
|
32
32
|
"lodash.identity": "^3.0.0",
|