@nestjs/core 6.11.7 → 6.11.11
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 +1 -1
- package/helpers/http-adapter-host.d.ts +7 -6
- package/hooks/before-app-shutdown.hook.js +4 -2
- package/hooks/on-app-bootstrap.hook.js +5 -2
- package/hooks/on-app-shutdown.hook.js +5 -2
- package/hooks/on-module-destroy.hook.js +5 -2
- package/hooks/on-module-init.hook.js +5 -2
- package/injector/container.d.ts +1 -1
- package/injector/instance-wrapper.d.ts +5 -4
- package/injector/internal-providers-storage.d.ts +3 -2
- package/injector/module.d.ts +15 -14
- package/middleware/utils.js +2 -2
- package/package.json +4 -4
- package/router/router-execution-context.js +1 -1
package/Readme.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
11
11
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
12
|
-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/
|
|
12
|
+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
|
13
13
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
|
14
14
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
|
15
15
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
|
@@ -18,11 +18,12 @@ export declare class HttpAdapterHost<T extends AbstractHttpAdapter = AbstractHtt
|
|
|
18
18
|
*
|
|
19
19
|
* @param httpAdapter reference to the `HttpAdapter` to be set
|
|
20
20
|
*/
|
|
21
|
+
set httpAdapter(httpAdapter: T);
|
|
21
22
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
httpAdapter: T;
|
|
23
|
+
* Accessor for the underlying `HttpAdapter`
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* `const httpAdapter = adapterHost.httpAdapter;`
|
|
27
|
+
*/
|
|
28
|
+
get httpAdapter(): T;
|
|
28
29
|
}
|
|
@@ -30,14 +30,16 @@ function callOperator(instances, signal) {
|
|
|
30
30
|
*/
|
|
31
31
|
async function callBeforeAppShutdownHook(module, signal) {
|
|
32
32
|
const providers = module.getNonAliasProviders();
|
|
33
|
-
const [_,
|
|
33
|
+
const [_, moduleClassHost] = providers.shift();
|
|
34
34
|
const instances = [...module.controllers, ...providers];
|
|
35
35
|
const nonTransientInstances = transient_instances_1.getNonTransientInstances(instances);
|
|
36
36
|
await Promise.all(callOperator(nonTransientInstances, signal));
|
|
37
37
|
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
38
38
|
await Promise.all(callOperator(transientInstances, signal));
|
|
39
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
39
40
|
if (moduleClassInstance &&
|
|
40
|
-
hasBeforeApplicationShutdownHook(moduleClassInstance)
|
|
41
|
+
hasBeforeApplicationShutdownHook(moduleClassInstance) &&
|
|
42
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
41
43
|
await moduleClassInstance.beforeApplicationShutdown(signal);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
@@ -31,7 +31,7 @@ async function callModuleBootstrapHook(module) {
|
|
|
31
31
|
const providers = module.getNonAliasProviders();
|
|
32
32
|
// Module (class) instance is the first element of the providers array
|
|
33
33
|
// Lifecycle hook has to be called once all classes are properly initialized
|
|
34
|
-
const [_,
|
|
34
|
+
const [_, moduleClassHost] = providers.shift();
|
|
35
35
|
const instances = [
|
|
36
36
|
...module.controllers,
|
|
37
37
|
...providers,
|
|
@@ -43,7 +43,10 @@ async function callModuleBootstrapHook(module) {
|
|
|
43
43
|
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
44
44
|
await Promise.all(callOperator(transientInstances));
|
|
45
45
|
// Call the instance itself
|
|
46
|
-
|
|
46
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
47
|
+
if (moduleClassInstance &&
|
|
48
|
+
hasOnAppBootstrapHook(moduleClassInstance) &&
|
|
49
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
47
50
|
await moduleClassInstance.onApplicationBootstrap();
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -31,7 +31,7 @@ async function callAppShutdownHook(module, signal) {
|
|
|
31
31
|
const providers = module.getNonAliasProviders();
|
|
32
32
|
// Module (class) instance is the first element of the providers array
|
|
33
33
|
// Lifecycle hook has to be called once all classes are properly initialized
|
|
34
|
-
const [_,
|
|
34
|
+
const [_, moduleClassHost] = providers.shift();
|
|
35
35
|
const instances = [
|
|
36
36
|
...module.controllers,
|
|
37
37
|
...providers,
|
|
@@ -43,7 +43,10 @@ async function callAppShutdownHook(module, signal) {
|
|
|
43
43
|
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
44
44
|
await Promise.all(callOperator(transientInstances, signal));
|
|
45
45
|
// Call the instance itself
|
|
46
|
-
|
|
46
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
47
|
+
if (moduleClassInstance &&
|
|
48
|
+
hasOnAppShutdownHook(moduleClassInstance) &&
|
|
49
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
47
50
|
await moduleClassInstance.onApplicationShutdown(signal);
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -31,7 +31,7 @@ async function callModuleDestroyHook(module) {
|
|
|
31
31
|
const providers = module.getNonAliasProviders();
|
|
32
32
|
// Module (class) instance is the first element of the providers array
|
|
33
33
|
// Lifecycle hook has to be called once all classes are properly destroyed
|
|
34
|
-
const [_,
|
|
34
|
+
const [_, moduleClassHost] = providers.shift();
|
|
35
35
|
const instances = [
|
|
36
36
|
...module.controllers,
|
|
37
37
|
...providers,
|
|
@@ -43,7 +43,10 @@ async function callModuleDestroyHook(module) {
|
|
|
43
43
|
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
44
44
|
await Promise.all(callOperator(transientInstances));
|
|
45
45
|
// Call the module instance itself
|
|
46
|
-
|
|
46
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
47
|
+
if (moduleClassInstance &&
|
|
48
|
+
hasOnModuleDestroyHook(moduleClassInstance) &&
|
|
49
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
47
50
|
await moduleClassInstance.onModuleDestroy();
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -31,7 +31,7 @@ async function callModuleInitHook(module) {
|
|
|
31
31
|
const providers = module.getNonAliasProviders();
|
|
32
32
|
// Module (class) instance is the first element of the providers array
|
|
33
33
|
// Lifecycle hook has to be called once all classes are properly initialized
|
|
34
|
-
const [_,
|
|
34
|
+
const [_, moduleClassHost] = providers.shift();
|
|
35
35
|
const instances = [
|
|
36
36
|
...module.controllers,
|
|
37
37
|
...providers,
|
|
@@ -43,7 +43,10 @@ async function callModuleInitHook(module) {
|
|
|
43
43
|
const transientInstances = transient_instances_1.getTransientInstances(instances);
|
|
44
44
|
await Promise.all(callOperator(transientInstances));
|
|
45
45
|
// Call the instance itself
|
|
46
|
-
|
|
46
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
47
|
+
if (moduleClassInstance &&
|
|
48
|
+
hasOnModuleInitHook(moduleClassInstance) &&
|
|
49
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
47
50
|
await moduleClassInstance.onModuleInit();
|
|
48
51
|
}
|
|
49
52
|
}
|
package/injector/container.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class NestContainer {
|
|
|
16
16
|
private readonly internalProvidersStorage;
|
|
17
17
|
private internalCoreModule;
|
|
18
18
|
constructor(_applicationConfig?: ApplicationConfig);
|
|
19
|
-
|
|
19
|
+
get applicationConfig(): ApplicationConfig | undefined;
|
|
20
20
|
setHttpAdapter(httpAdapter: any): void;
|
|
21
21
|
getHttpAdapterRef(): import("..").AbstractHttpAdapter<any, any, any>;
|
|
22
22
|
addModule(metatype: Type<any> | DynamicModule | Promise<DynamicModule>, scope: Type<any>[]): Promise<Module>;
|
|
@@ -30,10 +30,11 @@ export declare class InstanceWrapper<T = any> {
|
|
|
30
30
|
private transientMap?;
|
|
31
31
|
private isTreeStatic;
|
|
32
32
|
constructor(metadata?: Partial<InstanceWrapper<T>> & Partial<InstancePerContext<T>>);
|
|
33
|
-
|
|
34
|
-
instance: T;
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
get id(): string;
|
|
34
|
+
set instance(value: T);
|
|
35
|
+
get instance(): T;
|
|
36
|
+
get isNotMetatype(): boolean;
|
|
37
|
+
get isTransient(): boolean;
|
|
37
38
|
getInstanceByContextId(contextId: ContextId, inquirerId?: string): InstancePerContext<T>;
|
|
38
39
|
getInstanceByInquirerId(contextId: ContextId, inquirerId: string): InstancePerContext<T>;
|
|
39
40
|
setInstanceByContextId(contextId: ContextId, value: InstancePerContext<T>, inquirerId?: string): void;
|
|
@@ -3,6 +3,7 @@ import { AbstractHttpAdapter } from '../adapters';
|
|
|
3
3
|
export declare class InternalProvidersStorage {
|
|
4
4
|
private readonly _httpAdapterHost;
|
|
5
5
|
private _httpAdapter;
|
|
6
|
-
|
|
7
|
-
httpAdapter: AbstractHttpAdapter;
|
|
6
|
+
get httpAdapterHost(): HttpAdapterHost;
|
|
7
|
+
get httpAdapter(): AbstractHttpAdapter;
|
|
8
|
+
set httpAdapter(httpAdapter: AbstractHttpAdapter);
|
|
8
9
|
}
|
package/injector/module.d.ts
CHANGED
|
@@ -18,29 +18,30 @@ export declare class Module {
|
|
|
18
18
|
private readonly _exports;
|
|
19
19
|
private _distance;
|
|
20
20
|
constructor(_metatype: Type<any>, _scope: Type<any>[], container: NestContainer);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
get id(): string;
|
|
22
|
+
get scope(): Type<any>[];
|
|
23
|
+
get providers(): Map<any, InstanceWrapper<Injectable>>;
|
|
24
|
+
get middlewares(): Map<any, InstanceWrapper<Injectable>>;
|
|
25
|
+
get imports(): Set<Module>;
|
|
26
26
|
/**
|
|
27
27
|
* Left for backward-compatibility reasons
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
get relatedModules(): Set<Module>;
|
|
30
30
|
/**
|
|
31
31
|
* Left for backward-compatibility reasons
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
get components(): Map<string, InstanceWrapper<Injectable>>;
|
|
34
34
|
/**
|
|
35
35
|
* Left for backward-compatibility reasons
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
distance: number;
|
|
37
|
+
get routes(): Map<string, InstanceWrapper<Controller>>;
|
|
38
|
+
get injectables(): Map<string, InstanceWrapper<Injectable>>;
|
|
39
|
+
get controllers(): Map<string, InstanceWrapper<Controller>>;
|
|
40
|
+
get exports(): Set<string | symbol>;
|
|
41
|
+
get instance(): NestModule;
|
|
42
|
+
get metatype(): Type<any>;
|
|
43
|
+
get distance(): number;
|
|
44
|
+
set distance(value: number);
|
|
44
45
|
addCoreProviders(): void;
|
|
45
46
|
addModuleRef(): void;
|
|
46
47
|
addModuleAsProvider(): void;
|
package/middleware/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
4
|
-
const
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
5
|
exports.filterMiddleware = (middleware) => {
|
|
6
6
|
return []
|
|
7
7
|
.concat(middleware)
|
|
@@ -23,7 +23,7 @@ function isClass(middleware) {
|
|
|
23
23
|
}
|
|
24
24
|
exports.isClass = isClass;
|
|
25
25
|
function assignToken(metatype) {
|
|
26
|
-
Object.defineProperty(metatype, 'name', { value:
|
|
26
|
+
Object.defineProperty(metatype, 'name', { value: uuid_1.v4() });
|
|
27
27
|
return metatype;
|
|
28
28
|
}
|
|
29
29
|
exports.assignToken = assignToken;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "6.11.
|
|
3
|
+
"version": "6.11.11",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"@nuxtjs/opencollective": "0.2.2",
|
|
31
31
|
"fast-safe-stringify": "2.0.7",
|
|
32
32
|
"iterare": "1.2.0",
|
|
33
|
-
"object-hash": "2.0.
|
|
33
|
+
"object-hash": "2.0.3",
|
|
34
34
|
"path-to-regexp": "3.2.0",
|
|
35
|
-
"tslib": "1.
|
|
36
|
-
"uuid": "
|
|
35
|
+
"tslib": "1.11.1",
|
|
36
|
+
"uuid": "7.0.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@nestjs/common": "^6.0.0",
|
|
@@ -156,7 +156,7 @@ class RouterExecutionContext {
|
|
|
156
156
|
await this.responseController.render(result, res, renderTemplate);
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
if (redirectResponse && redirectResponse.url) {
|
|
159
|
+
if (redirectResponse && typeof redirectResponse.url === 'string') {
|
|
160
160
|
return async (result, res) => {
|
|
161
161
|
await this.responseController.redirect(result, res, redirectResponse);
|
|
162
162
|
};
|