@opra/nestjs 1.0.0-beta.1 → 1.0.0-beta.3
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/opra-http-core.module.js +1 -1
- package/cjs/opra-nestjs-adapter.js +3 -3
- package/cjs/services/opra-middleware.js +4 -4
- package/esm/opra-http-core.module.js +1 -1
- package/esm/opra-nestjs-adapter.js +2 -2
- package/esm/services/opra-middleware.js +1 -1
- package/package.json +6 -5
- package/types/opra-http.module.d.ts +1 -1
- package/types/opra-nestjs-adapter.d.ts +1 -1
- package/cjs/augmentation/http-controller.augmentation.js +0 -16
- package/esm/augmentation/http-controller.augmentation.js +0 -16
- package/types/augmentation/http-controller.augmentation.d.ts +0 -0
|
@@ -36,7 +36,7 @@ let OpraHttpCoreModule = OpraHttpCoreModule_1 = class OpraHttpCoreModule {
|
|
|
36
36
|
useFactory: async (moduleRef) => {
|
|
37
37
|
(0, ts_gems_1.asMutable)(opraAdapter).document = await common_2.ApiDocumentFactory.createDocument({
|
|
38
38
|
...init,
|
|
39
|
-
api: {
|
|
39
|
+
api: { transport: 'http', name: init.name, controllers: init.controllers },
|
|
40
40
|
});
|
|
41
41
|
opraAdapter.interceptors.map(x => {
|
|
42
42
|
if ((0, common_2.isConstructor)(x)) {
|
|
@@ -6,14 +6,14 @@ const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const constants_js_1 = require("@nestjs/common/constants.js");
|
|
8
8
|
const common_2 = require("@opra/common");
|
|
9
|
-
const
|
|
9
|
+
const http_1 = require("@opra/http");
|
|
10
10
|
const ts_gems_1 = require("ts-gems");
|
|
11
11
|
const public_decorator_js_1 = require("./decorators/public.decorator.js");
|
|
12
|
-
class OpraNestAdapter extends
|
|
12
|
+
class OpraNestAdapter extends http_1.HttpAdapter {
|
|
13
13
|
constructor(init, options) {
|
|
14
14
|
super((function () {
|
|
15
15
|
const document = new common_2.ApiDocument();
|
|
16
|
-
document.api = new common_2.HttpApi(document);
|
|
16
|
+
document.api = new common_2.HttpApi({ owner: document, name: init.name, transport: 'http' });
|
|
17
17
|
return document;
|
|
18
18
|
})(), {
|
|
19
19
|
...options,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OpraMiddleware = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
const
|
|
6
|
+
const http_1 = require("@opra/http");
|
|
7
7
|
const constants_js_1 = require("../constants.js");
|
|
8
8
|
const opra_nestjs_adapter_js_1 = require("../opra-nestjs-adapter.js");
|
|
9
9
|
let OpraMiddleware = class OpraMiddleware {
|
|
@@ -12,10 +12,10 @@ let OpraMiddleware = class OpraMiddleware {
|
|
|
12
12
|
this.options = options;
|
|
13
13
|
}
|
|
14
14
|
use(req, res, next) {
|
|
15
|
-
const request =
|
|
16
|
-
const response =
|
|
15
|
+
const request = http_1.HttpIncoming.from(req);
|
|
16
|
+
const response = http_1.HttpOutgoing.from(res);
|
|
17
17
|
/** Create the HttpContext */
|
|
18
|
-
const context = new
|
|
18
|
+
const context = new http_1.HttpContext({
|
|
19
19
|
adapter: this.opraAdapter,
|
|
20
20
|
platform: req.route ? 'express' : 'fastify',
|
|
21
21
|
request,
|
|
@@ -33,7 +33,7 @@ let OpraHttpCoreModule = OpraHttpCoreModule_1 = class OpraHttpCoreModule {
|
|
|
33
33
|
useFactory: async (moduleRef) => {
|
|
34
34
|
asMutable(opraAdapter).document = await ApiDocumentFactory.createDocument({
|
|
35
35
|
...init,
|
|
36
|
-
api: {
|
|
36
|
+
api: { transport: 'http', name: init.name, controllers: init.controllers },
|
|
37
37
|
});
|
|
38
38
|
opraAdapter.interceptors.map(x => {
|
|
39
39
|
if (isConstructor(x)) {
|
|
@@ -3,14 +3,14 @@ import nodePath from 'node:path';
|
|
|
3
3
|
import { Controller, Delete, Get, Head, Next, Options, Patch, Post, Put, Req, Res, Search, } from '@nestjs/common';
|
|
4
4
|
import { EXCEPTION_FILTERS_METADATA, GUARDS_METADATA, INTERCEPTORS_METADATA } from '@nestjs/common/constants.js';
|
|
5
5
|
import { ApiDocument, HTTP_CONTROLLER_METADATA, HttpApi, isConstructor, NotFoundError, } from '@opra/common';
|
|
6
|
-
import { HttpAdapter } from '@opra/
|
|
6
|
+
import { HttpAdapter } from '@opra/http';
|
|
7
7
|
import { asMutable } from 'ts-gems';
|
|
8
8
|
import { Public } from './decorators/public.decorator.js';
|
|
9
9
|
export class OpraNestAdapter extends HttpAdapter {
|
|
10
10
|
constructor(init, options) {
|
|
11
11
|
super((function () {
|
|
12
12
|
const document = new ApiDocument();
|
|
13
|
-
document.api = new HttpApi(document);
|
|
13
|
+
document.api = new HttpApi({ owner: document, name: init.name, transport: 'http' });
|
|
14
14
|
return document;
|
|
15
15
|
})(), {
|
|
16
16
|
...options,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata, __param } from "tslib";
|
|
2
2
|
import { Inject, Injectable } from '@nestjs/common';
|
|
3
|
-
import { HttpContext, HttpIncoming, HttpOutgoing } from '@opra/
|
|
3
|
+
import { HttpContext, HttpIncoming, HttpOutgoing } from '@opra/http';
|
|
4
4
|
import { OPRA_HTTP_MODULE_OPTIONS } from '../constants.js';
|
|
5
5
|
import { OpraNestAdapter } from '../opra-nestjs-adapter.js';
|
|
6
6
|
let OpraMiddleware = class OpraMiddleware {
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/nestjs",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Opra NestJS module",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@opra/common": "^1.0.0-beta.
|
|
9
|
-
"@opra/core": "^1.0.0-beta.
|
|
8
|
+
"@opra/common": "^1.0.0-beta.3",
|
|
9
|
+
"@opra/core": "^1.0.0-beta.3",
|
|
10
|
+
"@opra/http": "^1.0.0-beta.3",
|
|
10
11
|
"fast-tokenizer": "^1.7.0",
|
|
11
12
|
"lodash.head": "^4.0.1",
|
|
12
13
|
"putil-promisify": "^1.10.1",
|
|
@@ -14,8 +15,8 @@
|
|
|
14
15
|
"tslib": "^2.7.0"
|
|
15
16
|
},
|
|
16
17
|
"peerDependencies": {
|
|
17
|
-
"@nestjs/common": "^10.4.
|
|
18
|
-
"@nestjs/core": "^10.4.
|
|
18
|
+
"@nestjs/common": "^10.4.4",
|
|
19
|
+
"@nestjs/core": "^10.4.4"
|
|
19
20
|
},
|
|
20
21
|
"type": "module",
|
|
21
22
|
"exports": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DynamicModule, type Type } from '@nestjs/common';
|
|
2
2
|
import { ApiDocumentFactory } from '@opra/common';
|
|
3
|
-
import { HttpAdapter } from '@opra/
|
|
3
|
+
import { HttpAdapter } from '@opra/http';
|
|
4
4
|
export declare namespace OpraHttpModule {
|
|
5
5
|
interface Initiator extends Pick<DynamicModule, 'imports' | 'providers' | 'exports' | 'controllers'>, Pick<ApiDocumentFactory.InitArguments, 'types' | 'references' | 'info'> {
|
|
6
6
|
id?: any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Type } from '@nestjs/common';
|
|
2
|
-
import { HttpAdapter } from '@opra/
|
|
2
|
+
import { HttpAdapter } from '@opra/http';
|
|
3
3
|
import type { OpraHttpModule } from './opra-http.module.js';
|
|
4
4
|
export declare class OpraNestAdapter extends HttpAdapter {
|
|
5
5
|
readonly nestControllers: Type[];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Controller } from '@nestjs/common';
|
|
3
|
-
// import { DECORATOR, HttpController } from '@opra/common';
|
|
4
|
-
//
|
|
5
|
-
// /*
|
|
6
|
-
// Overrides HttpController decorator function to call NestJS's Controller() when decorator called
|
|
7
|
-
// */
|
|
8
|
-
// const oldHttpControllerDecorator = HttpController[DECORATOR];
|
|
9
|
-
// HttpController[DECORATOR] = function HttpControllerDecorator(options?: HttpController.Options) {
|
|
10
|
-
// const opraControllerDecorator = oldHttpControllerDecorator(options);
|
|
11
|
-
// const nestControllerDecorator = Controller({});
|
|
12
|
-
// return (target: Function) => {
|
|
13
|
-
// opraControllerDecorator(target);
|
|
14
|
-
// nestControllerDecorator(target);
|
|
15
|
-
// };
|
|
16
|
-
// };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Controller } from '@nestjs/common';
|
|
3
|
-
// import { DECORATOR, HttpController } from '@opra/common';
|
|
4
|
-
//
|
|
5
|
-
// /*
|
|
6
|
-
// Overrides HttpController decorator function to call NestJS's Controller() when decorator called
|
|
7
|
-
// */
|
|
8
|
-
// const oldHttpControllerDecorator = HttpController[DECORATOR];
|
|
9
|
-
// HttpController[DECORATOR] = function HttpControllerDecorator(options?: HttpController.Options) {
|
|
10
|
-
// const opraControllerDecorator = oldHttpControllerDecorator(options);
|
|
11
|
-
// const nestControllerDecorator = Controller({});
|
|
12
|
-
// return (target: Function) => {
|
|
13
|
-
// opraControllerDecorator(target);
|
|
14
|
-
// nestControllerDecorator(target);
|
|
15
|
-
// };
|
|
16
|
-
// };
|
|
File without changes
|