@opra/nestjs 1.0.0-beta.5 → 1.0.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.
- package/cjs/base-nestjs-adapter.js +15 -0
- package/cjs/kafka/opra-kafka-nestjs-adapter.js +17 -15
- package/esm/base-nestjs-adapter.js +11 -0
- package/esm/kafka/opra-kafka-nestjs-adapter.js +17 -15
- package/package.json +5 -5
- package/types/base-nestjs-adapter.d.ts +5 -0
- package/types/kafka/opra-kafka-nestjs-adapter.d.ts +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseNestAdapter = void 0;
|
|
4
|
+
// import { Injector } from '@nestjs/core/injector/injector';
|
|
5
|
+
// import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
6
|
+
// import { Module } from '@nestjs/core/injector/module';
|
|
7
|
+
// import { REQUEST_CONTEXT_ID } from '@nestjs/core/router/request/request-constants';
|
|
8
|
+
// import { BaseRpcContext, PatternMetadata } from '@nestjs/microservices';
|
|
9
|
+
// import { RequestContextHost } from '@nestjs/microservices/context/request-context-host';
|
|
10
|
+
class BaseNestAdapter {
|
|
11
|
+
constructor(moduleRef) {
|
|
12
|
+
this.moduleRef = moduleRef;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.BaseNestAdapter = BaseNestAdapter;
|
|
@@ -4,12 +4,13 @@ exports.OpraKafkaNestjsAdapter = void 0;
|
|
|
4
4
|
const index_1 = require("@nestjs/core/errors/exceptions/index");
|
|
5
5
|
const common_1 = require("@opra/common");
|
|
6
6
|
const kafka_1 = require("@opra/kafka");
|
|
7
|
+
const base_nestjs_adapter_js_1 = require("../base-nestjs-adapter.js");
|
|
7
8
|
/**
|
|
8
9
|
* @class
|
|
9
10
|
*/
|
|
10
|
-
class OpraKafkaNestjsAdapter {
|
|
11
|
+
class OpraKafkaNestjsAdapter extends base_nestjs_adapter_js_1.BaseNestAdapter {
|
|
11
12
|
constructor(moduleRef) {
|
|
12
|
-
|
|
13
|
+
super(moduleRef);
|
|
13
14
|
}
|
|
14
15
|
get document() {
|
|
15
16
|
if (!this._document)
|
|
@@ -55,25 +56,26 @@ class OpraKafkaNestjsAdapter {
|
|
|
55
56
|
_scanControllers() {
|
|
56
57
|
const container = this.moduleRef.container;
|
|
57
58
|
const modules = container.getModules();
|
|
58
|
-
const
|
|
59
|
+
const out = [];
|
|
59
60
|
modules.forEach(({ controllers }) => {
|
|
60
61
|
controllers.forEach(wrapper => {
|
|
61
62
|
const ctor = Object.getPrototypeOf(wrapper.instance).constructor;
|
|
62
63
|
const metadata = Reflect.getMetadata(common_1.RPC_CONTROLLER_METADATA, ctor);
|
|
63
|
-
if (metadata)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
64
|
+
if (!metadata)
|
|
65
|
+
return;
|
|
66
|
+
const instance = {};
|
|
67
|
+
Object.setPrototypeOf(instance, wrapper.instance);
|
|
68
|
+
out.push(wrapper.instance);
|
|
69
|
+
// if (metadata.operations) {
|
|
70
|
+
// for (const [k, _] of Object.keys(metadata.operations)) {
|
|
71
|
+
// const isRequestScoped = !wrapper.isDependencyTreeStatic();
|
|
72
|
+
// // const fn = instance[k];
|
|
73
|
+
// // instance[k] = fn;
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
74
76
|
});
|
|
75
77
|
});
|
|
76
|
-
return
|
|
78
|
+
return out;
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
exports.OpraKafkaNestjsAdapter = OpraKafkaNestjsAdapter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// import { Injector } from '@nestjs/core/injector/injector';
|
|
2
|
+
// import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
3
|
+
// import { Module } from '@nestjs/core/injector/module';
|
|
4
|
+
// import { REQUEST_CONTEXT_ID } from '@nestjs/core/router/request/request-constants';
|
|
5
|
+
// import { BaseRpcContext, PatternMetadata } from '@nestjs/microservices';
|
|
6
|
+
// import { RequestContextHost } from '@nestjs/microservices/context/request-context-host';
|
|
7
|
+
export class BaseNestAdapter {
|
|
8
|
+
constructor(moduleRef) {
|
|
9
|
+
this.moduleRef = moduleRef;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { RuntimeException } from '@nestjs/core/errors/exceptions/index';
|
|
2
2
|
import { ApiDocumentFactory, RPC_CONTROLLER_METADATA } from '@opra/common';
|
|
3
3
|
import { KafkaAdapter } from '@opra/kafka';
|
|
4
|
+
import { BaseNestAdapter } from '../base-nestjs-adapter.js';
|
|
4
5
|
/**
|
|
5
6
|
* @class
|
|
6
7
|
*/
|
|
7
|
-
export class OpraKafkaNestjsAdapter {
|
|
8
|
+
export class OpraKafkaNestjsAdapter extends BaseNestAdapter {
|
|
8
9
|
constructor(moduleRef) {
|
|
9
|
-
|
|
10
|
+
super(moduleRef);
|
|
10
11
|
}
|
|
11
12
|
get document() {
|
|
12
13
|
if (!this._document)
|
|
@@ -52,24 +53,25 @@ export class OpraKafkaNestjsAdapter {
|
|
|
52
53
|
_scanControllers() {
|
|
53
54
|
const container = this.moduleRef.container;
|
|
54
55
|
const modules = container.getModules();
|
|
55
|
-
const
|
|
56
|
+
const out = [];
|
|
56
57
|
modules.forEach(({ controllers }) => {
|
|
57
58
|
controllers.forEach(wrapper => {
|
|
58
59
|
const ctor = Object.getPrototypeOf(wrapper.instance).constructor;
|
|
59
60
|
const metadata = Reflect.getMetadata(RPC_CONTROLLER_METADATA, ctor);
|
|
60
|
-
if (metadata)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
61
|
+
if (!metadata)
|
|
62
|
+
return;
|
|
63
|
+
const instance = {};
|
|
64
|
+
Object.setPrototypeOf(instance, wrapper.instance);
|
|
65
|
+
out.push(wrapper.instance);
|
|
66
|
+
// if (metadata.operations) {
|
|
67
|
+
// for (const [k, _] of Object.keys(metadata.operations)) {
|
|
68
|
+
// const isRequestScoped = !wrapper.isDependencyTreeStatic();
|
|
69
|
+
// // const fn = instance[k];
|
|
70
|
+
// // instance[k] = fn;
|
|
71
|
+
// }
|
|
72
|
+
// }
|
|
71
73
|
});
|
|
72
74
|
});
|
|
73
|
-
return
|
|
75
|
+
return out;
|
|
74
76
|
}
|
|
75
77
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/nestjs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Opra NestJS module",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@opra/common": "^1.0.
|
|
9
|
-
"@opra/core": "^1.0.
|
|
8
|
+
"@opra/common": "^1.0.1",
|
|
9
|
+
"@opra/core": "^1.0.1",
|
|
10
10
|
"fast-tokenizer": "^1.7.0",
|
|
11
11
|
"lodash.head": "^4.0.1",
|
|
12
12
|
"putil-promisify": "^1.10.1",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"optionalDependencies": {
|
|
21
21
|
"@nestjs/microservices": "^10.4.4",
|
|
22
|
-
"@opra/http": "^1.0.
|
|
23
|
-
"@opra/kafka": "^1.0.
|
|
22
|
+
"@opra/http": "^1.0.1",
|
|
23
|
+
"@opra/kafka": "^1.0.1"
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
26
26
|
"exports": {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ModuleRef } from '@nestjs/core';
|
|
2
2
|
import { ApiDocument } from '@opra/common';
|
|
3
3
|
import { KafkaAdapter } from '@opra/kafka';
|
|
4
|
+
import { BaseNestAdapter } from '../base-nestjs-adapter.js';
|
|
4
5
|
import type { OpraKafkaModule } from './opra-kafka.module.js';
|
|
5
6
|
/**
|
|
6
7
|
* @class
|
|
7
8
|
*/
|
|
8
|
-
export declare class OpraKafkaNestjsAdapter {
|
|
9
|
-
protected moduleRef: ModuleRef;
|
|
9
|
+
export declare class OpraKafkaNestjsAdapter extends BaseNestAdapter {
|
|
10
10
|
private _adapter?;
|
|
11
11
|
private _document?;
|
|
12
12
|
constructor(moduleRef: ModuleRef);
|