@nestjs/core 5.4.0 → 5.4.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/Readme.md +4 -4
- package/exceptions/base-exception-filter.d.ts +3 -1
- package/exceptions/base-exception-filter.js +19 -2
- package/exceptions/exceptions-handler.d.ts +1 -2
- package/exceptions/exceptions-handler.js +2 -2
- package/injector/injector.js +3 -1
- package/injector/module.d.ts +4 -4
- package/injector/module.js +1 -1
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
|
15
15
|
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
|
16
16
|
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
|
17
|
-
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#
|
|
17
|
+
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#8" alt="Coverage" /></a>
|
|
18
18
|
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
|
19
19
|
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
20
20
|
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
@@ -53,12 +53,12 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
53
53
|
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="220" /></a>
|
|
54
54
|
|
|
55
55
|
#### Silver Sponsors
|
|
56
|
-
|
|
57
|
-
<a href="
|
|
56
|
+
<a href="https://neoteric.eu/"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" /></a>
|
|
57
|
+
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="bottom" height="95" /></a> <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /> </a>
|
|
58
58
|
|
|
59
59
|
#### Sponsors
|
|
60
60
|
|
|
61
|
-
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a>
|
|
61
|
+
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="38" /></a> <a href="http://architectnow.net/"><img src="https://nestjs.com/img/architectnow.png" height="24" /></a> <a href="https://quander.io/"><img src="https://nestjs.com/img/quander.png" height="28" /></a>
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
## Backers
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ArgumentsHost, ExceptionFilter, HttpServer } from '@nestjs/common';
|
|
2
|
+
import { ApplicationReferenceHost } from './../helpers/application-ref-host';
|
|
2
3
|
export declare class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
|
|
3
4
|
protected readonly applicationRef: HttpServer;
|
|
4
5
|
private static readonly logger;
|
|
5
|
-
|
|
6
|
+
protected readonly applicationRefHost?: ApplicationReferenceHost;
|
|
7
|
+
constructor(applicationRef?: HttpServer);
|
|
6
8
|
catch(exception: T, host: ArgumentsHost): void;
|
|
7
9
|
isExceptionObject(err: any): err is Error;
|
|
8
10
|
}
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const common_1 = require("@nestjs/common");
|
|
4
13
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
5
14
|
const constants_1 = require("../constants");
|
|
15
|
+
const application_ref_host_1 = require("./../helpers/application-ref-host");
|
|
6
16
|
class BaseExceptionFilter {
|
|
7
17
|
constructor(applicationRef) {
|
|
8
18
|
this.applicationRef = applicationRef;
|
|
9
19
|
}
|
|
10
20
|
catch(exception, host) {
|
|
21
|
+
const applicationRef = this.applicationRef ||
|
|
22
|
+
(this.applicationRefHost && this.applicationRefHost.applicationRef);
|
|
11
23
|
if (!(exception instanceof common_1.HttpException)) {
|
|
12
24
|
const body = {
|
|
13
25
|
statusCode: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
14
26
|
message: constants_1.MESSAGES.UNKNOWN_EXCEPTION_MESSAGE,
|
|
15
27
|
};
|
|
16
|
-
|
|
28
|
+
applicationRef.reply(host.getArgByIndex(1), body, body.statusCode);
|
|
17
29
|
if (this.isExceptionObject(exception)) {
|
|
18
30
|
return BaseExceptionFilter.logger.error(exception.message, exception.stack);
|
|
19
31
|
}
|
|
@@ -26,11 +38,16 @@ class BaseExceptionFilter {
|
|
|
26
38
|
statusCode: exception.getStatus(),
|
|
27
39
|
message: res,
|
|
28
40
|
};
|
|
29
|
-
|
|
41
|
+
applicationRef.reply(host.getArgByIndex(1), message, exception.getStatus());
|
|
30
42
|
}
|
|
31
43
|
isExceptionObject(err) {
|
|
32
44
|
return shared_utils_1.isObject(err) && !!err.message;
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
47
|
BaseExceptionFilter.logger = new common_1.Logger('ExceptionsHandler');
|
|
48
|
+
__decorate([
|
|
49
|
+
common_1.Optional(),
|
|
50
|
+
common_1.Inject(),
|
|
51
|
+
__metadata("design:type", application_ref_host_1.ApplicationReferenceHost)
|
|
52
|
+
], BaseExceptionFilter.prototype, "applicationRefHost", void 0);
|
|
36
53
|
exports.BaseExceptionFilter = BaseExceptionFilter;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { HttpException
|
|
1
|
+
import { HttpException } from '@nestjs/common';
|
|
2
2
|
import { ExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions/exception-filter-metadata.interface';
|
|
3
3
|
import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
|
|
4
4
|
import { BaseExceptionFilter } from './base-exception-filter';
|
|
5
5
|
export declare class ExceptionsHandler extends BaseExceptionFilter {
|
|
6
6
|
private filters;
|
|
7
|
-
constructor(applicationRef: HttpServer);
|
|
8
7
|
next(exception: Error | HttpException | any, ctx: ArgumentsHost): void;
|
|
9
8
|
setCustomFilters(filters: ExceptionFilterMetadata[]): void;
|
|
10
9
|
invokeCustomFilters(exception: any, response: any): boolean;
|
|
@@ -4,8 +4,8 @@ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
|
4
4
|
const invalid_exception_filter_exception_1 = require("../errors/exceptions/invalid-exception-filter.exception");
|
|
5
5
|
const base_exception_filter_1 = require("./base-exception-filter");
|
|
6
6
|
class ExceptionsHandler extends base_exception_filter_1.BaseExceptionFilter {
|
|
7
|
-
constructor(
|
|
8
|
-
super(
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
9
|
this.filters = [];
|
|
10
10
|
}
|
|
11
11
|
next(exception, ctx) {
|
package/injector/injector.js
CHANGED
|
@@ -209,7 +209,9 @@ class Injector {
|
|
|
209
209
|
async instantiateClass(instances, wrapper, targetMetatype) {
|
|
210
210
|
const { metatype, inject } = wrapper;
|
|
211
211
|
if (shared_utils_1.isNil(inject)) {
|
|
212
|
-
targetMetatype.instance =
|
|
212
|
+
targetMetatype.instance = wrapper.forwardRef
|
|
213
|
+
? Object.assign(targetMetatype.instance, new metatype(...instances))
|
|
214
|
+
: new metatype(...instances);
|
|
213
215
|
}
|
|
214
216
|
else {
|
|
215
217
|
const factoryResult = targetMetatype.metatype(...instances);
|
package/injector/module.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare class Module {
|
|
|
38
38
|
readonly components: Map<string, InstanceWrapper<Injectable>>;
|
|
39
39
|
readonly injectables: Map<string, InstanceWrapper<Injectable>>;
|
|
40
40
|
readonly routes: Map<string, InstanceWrapper<Controller>>;
|
|
41
|
-
readonly exports: Set<string>;
|
|
41
|
+
readonly exports: Set<string | symbol>;
|
|
42
42
|
readonly instance: NestModule;
|
|
43
43
|
readonly metatype: Type<any>;
|
|
44
44
|
addCoreInjectables(container: NestContainer): void;
|
|
@@ -60,9 +60,9 @@ export declare class Module {
|
|
|
60
60
|
addCustomClass(component: CustomClass, collection: Map<string, any>): void;
|
|
61
61
|
addCustomValue(component: CustomValue, collection: Map<string, any>): void;
|
|
62
62
|
addCustomFactory(component: CustomFactory, collection: Map<string, any>): void;
|
|
63
|
-
addExportedComponent(exportedComponent: ComponentMetatype | string | DynamicModule): Set<string>;
|
|
64
|
-
addCustomExportedComponent(exportedComponent: CustomFactory | CustomValue | CustomClass): Set<string>;
|
|
65
|
-
validateExportedProvider(token: string): string;
|
|
63
|
+
addExportedComponent(exportedComponent: ComponentMetatype | string | symbol | DynamicModule): Set<string | symbol>;
|
|
64
|
+
addCustomExportedComponent(exportedComponent: CustomFactory | CustomValue | CustomClass): Set<string | symbol>;
|
|
65
|
+
validateExportedProvider(token: string | symbol): string | symbol;
|
|
66
66
|
addRoute(route: Type<Controller>): void;
|
|
67
67
|
addRelatedModule(relatedModule: any): void;
|
|
68
68
|
replace(toReplace: any, options: any): string;
|
package/injector/module.js
CHANGED
|
@@ -207,7 +207,7 @@ class Module {
|
|
|
207
207
|
if (this.isCustomProvider(exportedComponent)) {
|
|
208
208
|
return this.addCustomExportedComponent(exportedComponent);
|
|
209
209
|
}
|
|
210
|
-
else if (shared_utils_1.isString(exportedComponent)) {
|
|
210
|
+
else if (shared_utils_1.isString(exportedComponent) || shared_utils_1.isSymbol(exportedComponent)) {
|
|
211
211
|
return addExportedUnit(exportedComponent);
|
|
212
212
|
}
|
|
213
213
|
else if (this.isDynamicModule(exportedComponent)) {
|