@opra/nestjs 0.29.0 → 0.30.0
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/augmentation/nestjs.augmentation.js +11 -0
- package/cjs/index.js +1 -0
- package/cjs/services/opra-api-loader.js +2 -1
- package/cjs/services/opra-exception-filter.js +16 -0
- package/esm/augmentation/nestjs.augmentation.js +9 -0
- package/esm/index.js +1 -0
- package/esm/services/opra-api-loader.js +2 -1
- package/esm/services/opra-exception-filter.js +13 -0
- package/package.json +6 -5
- package/types/augmentation/nestjs.augmentation.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/services/opra-exception-filter.d.ts +4 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const external_exception_filter_1 = require("@nestjs/core/exceptions/external-exception-filter");
|
|
4
|
+
const oldCatchMethod = external_exception_filter_1.ExternalExceptionFilter.prototype.catch;
|
|
5
|
+
external_exception_filter_1.ExternalExceptionFilter.prototype.catch = function (exception, host) {
|
|
6
|
+
const opraContext = host.getArgByIndex(3);
|
|
7
|
+
// Prevents error logging for all Opra controllers
|
|
8
|
+
if (opraContext && opraContext.request && opraContext.response)
|
|
9
|
+
throw exception;
|
|
10
|
+
oldCatchMethod(exception, host);
|
|
11
|
+
};
|
package/cjs/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
require("reflect-metadata");
|
|
5
5
|
require("./augmentation/common-decorator.augmentation.js");
|
|
6
|
+
require("./augmentation/nestjs.augmentation.js");
|
|
6
7
|
tslib_1.__exportStar(require("./opra.module.js"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./decorators/context.decorator.js"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./interfaces/opra-module-options.interface.js"), exports);
|
|
@@ -58,7 +58,8 @@ class OpraApiLoader {
|
|
|
58
58
|
if (!httpAdapter)
|
|
59
59
|
throw new Error('HttpAdapterHost is not initialized');
|
|
60
60
|
const app = httpAdapter.getInstance();
|
|
61
|
-
const logger = moduleOptions.logger ||
|
|
61
|
+
const logger = moduleOptions.logger ||
|
|
62
|
+
(process.env.NODE_ENV === 'test' ? undefined : new common_1.Logger(apiDocument.info.title));
|
|
62
63
|
return await core_2.ExpressAdapter.create(app, apiDocument, {
|
|
63
64
|
...moduleOptions,
|
|
64
65
|
logger,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpraExceptionFilter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const common_2 = require("@opra/common");
|
|
7
|
+
let OpraExceptionFilter = exports.OpraExceptionFilter = class OpraExceptionFilter {
|
|
8
|
+
catch(exception) {
|
|
9
|
+
if (exception instanceof common_2.OpraException)
|
|
10
|
+
return true;
|
|
11
|
+
throw exception;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
exports.OpraExceptionFilter = OpraExceptionFilter = tslib_1.__decorate([
|
|
15
|
+
(0, common_1.Catch)(common_2.OpraException)
|
|
16
|
+
], OpraExceptionFilter);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExternalExceptionFilter } from '@nestjs/core/exceptions/external-exception-filter';
|
|
2
|
+
const oldCatchMethod = ExternalExceptionFilter.prototype.catch;
|
|
3
|
+
ExternalExceptionFilter.prototype.catch = function (exception, host) {
|
|
4
|
+
const opraContext = host.getArgByIndex(3);
|
|
5
|
+
// Prevents error logging for all Opra controllers
|
|
6
|
+
if (opraContext && opraContext.request && opraContext.response)
|
|
7
|
+
throw exception;
|
|
8
|
+
oldCatchMethod(exception, host);
|
|
9
|
+
};
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import './augmentation/common-decorator.augmentation.js';
|
|
3
|
+
import './augmentation/nestjs.augmentation.js';
|
|
3
4
|
export * from './opra.module.js';
|
|
4
5
|
export * from './decorators/context.decorator.js';
|
|
5
6
|
export * from './interfaces/opra-module-options.interface.js';
|
|
@@ -55,7 +55,8 @@ export class OpraApiLoader {
|
|
|
55
55
|
if (!httpAdapter)
|
|
56
56
|
throw new Error('HttpAdapterHost is not initialized');
|
|
57
57
|
const app = httpAdapter.getInstance();
|
|
58
|
-
const logger = moduleOptions.logger ||
|
|
58
|
+
const logger = moduleOptions.logger ||
|
|
59
|
+
(process.env.NODE_ENV === 'test' ? undefined : new Logger(apiDocument.info.title));
|
|
59
60
|
return await ExpressAdapter.create(app, apiDocument, {
|
|
60
61
|
...moduleOptions,
|
|
61
62
|
logger,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { Catch } from '@nestjs/common';
|
|
3
|
+
import { OpraException } from '@opra/common';
|
|
4
|
+
export let OpraExceptionFilter = class OpraExceptionFilter {
|
|
5
|
+
catch(exception) {
|
|
6
|
+
if (exception instanceof OpraException)
|
|
7
|
+
return true;
|
|
8
|
+
throw exception;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
OpraExceptionFilter = __decorate([
|
|
12
|
+
Catch(OpraException)
|
|
13
|
+
], OpraExceptionFilter);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/nestjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "Opra NestJS module",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,14 +25,15 @@
|
|
|
25
25
|
"clean:cover": "rimraf ../../coverage/nestjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@opra/common": "^0.
|
|
29
|
-
"@opra/core": "^0.
|
|
28
|
+
"@opra/common": "^0.30.0",
|
|
29
|
+
"@opra/core": "^0.30.0",
|
|
30
30
|
"fast-tokenizer": "^1.2.2",
|
|
31
31
|
"lodash.head": "^4.0.1",
|
|
32
32
|
"reflect-metadata": "^0.1.13"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@nestjs/common": "^10.2.7"
|
|
35
|
+
"@nestjs/common": "^10.2.7",
|
|
36
|
+
"@nestjs/core": "^10.2.7"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@nestjs/platform-express": "^10.2.7",
|
|
@@ -61,4 +62,4 @@
|
|
|
61
62
|
"opra",
|
|
62
63
|
"nestjs"
|
|
63
64
|
]
|
|
64
|
-
}
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import './augmentation/common-decorator.augmentation.js';
|
|
3
|
+
import './augmentation/nestjs.augmentation.js';
|
|
3
4
|
export * from './opra.module.js';
|
|
4
5
|
export * from './decorators/context.decorator.js';
|
|
5
6
|
export * from './interfaces/opra-module-options.interface.js';
|