@nestjs/core 6.11.4 → 6.11.8

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 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/core.svg" alt="NPM Downloads" /></a>
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>
@@ -1,2 +1,5 @@
1
+ /**
2
+ * @publicApi
3
+ */
1
4
  export declare class DiscoveryModule {
2
5
  }
@@ -4,6 +4,9 @@ const tslib_1 = require("tslib");
4
4
  const common_1 = require("@nestjs/common");
5
5
  const metadata_scanner_1 = require("../metadata-scanner");
6
6
  const discovery_service_1 = require("./discovery-service");
7
+ /**
8
+ * @publicApi
9
+ */
7
10
  let DiscoveryModule = class DiscoveryModule {
8
11
  };
9
12
  DiscoveryModule = tslib_1.__decorate([
@@ -1,9 +1,15 @@
1
1
  import { InstanceWrapper } from '../injector/instance-wrapper';
2
2
  import { Module } from '../injector/module';
3
3
  import { ModulesContainer } from '../injector/modules-container';
4
+ /**
5
+ * @publicApi
6
+ */
4
7
  export interface DiscoveryOptions {
5
8
  include?: Function[];
6
9
  }
10
+ /**
11
+ * @publicApi
12
+ */
7
13
  export declare class DiscoveryService {
8
14
  private readonly modulesContainer;
9
15
  constructor(modulesContainer: ModulesContainer);
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const common_1 = require("@nestjs/common");
5
5
  const modules_container_1 = require("../injector/modules-container");
6
+ /**
7
+ * @publicApi
8
+ */
6
9
  let DiscoveryService = class DiscoveryService {
7
10
  constructor(modulesContainer) {
8
11
  this.modulesContainer = modulesContainer;
@@ -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 [_, { instance: moduleClassInstance }] = providers.shift();
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 [_, { instance: moduleClassInstance }] = providers.shift();
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
- if (moduleClassInstance && hasOnAppBootstrapHook(moduleClassInstance)) {
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 [_, { instance: moduleClassInstance }] = providers.shift();
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
- if (moduleClassInstance && hasOnAppShutdownHook(moduleClassInstance)) {
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 [_, { instance: moduleClassInstance }] = providers.shift();
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
- if (moduleClassInstance && hasOnModuleDestroyHook(moduleClassInstance)) {
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 [_, { instance: moduleClassInstance }] = providers.shift();
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
- if (moduleClassInstance && hasOnModuleInitHook(moduleClassInstance)) {
46
+ const moduleClassInstance = moduleClassHost.instance;
47
+ if (moduleClassInstance &&
48
+ hasOnModuleInitHook(moduleClassInstance) &&
49
+ moduleClassHost.isDependencyTreeStatic()) {
47
50
  await moduleClassInstance.onModuleInit();
48
51
  }
49
52
  }
@@ -14,6 +14,7 @@ export declare class NestApplicationContext implements INestApplicationContext {
14
14
  private contextModule;
15
15
  protected isInitialized: boolean;
16
16
  protected readonly injector: Injector;
17
+ private shutdownCleanupRef?;
17
18
  private readonly activeShutdownSignals;
18
19
  private readonly containerScanner;
19
20
  constructor(container: NestContainer, scope?: Type<any>[], contextModule?: Module);
@@ -52,6 +53,10 @@ export declare class NestApplicationContext implements INestApplicationContext {
52
53
  * @param {string[]} signals The system signals it should listen to
53
54
  */
54
55
  protected listenToShutdownSignals(signals: string[]): void;
56
+ /**
57
+ * Unsubscribes from shutdown signals (process events)
58
+ */
59
+ protected unsubscribeFromProcessSignals(): void;
55
60
  /**
56
61
  * Calls the `onModuleInit` function on the registered
57
62
  * modules and its children.
@@ -67,6 +67,7 @@ class NestApplicationContext {
67
67
  await this.callBeforeShutdownHook();
68
68
  await this.dispose();
69
69
  await this.callShutdownHook();
70
+ await this.unsubscribeFromProcessSignals();
70
71
  }
71
72
  useLogger(logger) {
72
73
  common_1.Logger.overrideLogger(logger);
@@ -125,11 +126,23 @@ class NestApplicationContext {
125
126
  process.exit(1);
126
127
  }
127
128
  };
129
+ this.shutdownCleanupRef = cleanup;
128
130
  signals.forEach((signal) => {
129
131
  this.activeShutdownSignals.push(signal);
130
132
  process.on(signal, cleanup);
131
133
  });
132
134
  }
135
+ /**
136
+ * Unsubscribes from shutdown signals (process events)
137
+ */
138
+ unsubscribeFromProcessSignals() {
139
+ if (!this.shutdownCleanupRef) {
140
+ return;
141
+ }
142
+ this.activeShutdownSignals.forEach(signal => {
143
+ process.removeListener(signal, this.shutdownCleanupRef);
144
+ });
145
+ }
133
146
  /**
134
147
  * Calls the `onModuleInit` function on the registered
135
148
  * modules and its children.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/core",
3
- "version": "6.11.4",
3
+ "version": "6.11.8",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@core)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
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.1",
33
+ "object-hash": "2.0.3",
34
34
  "path-to-regexp": "3.2.0",
35
35
  "tslib": "1.10.0",
36
36
  "uuid": "3.4.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
  };
@@ -5,7 +5,7 @@ export interface CustomHeader {
5
5
  }
6
6
  export interface RedirectResponse {
7
7
  url: string;
8
- statusCode: number;
8
+ statusCode?: number;
9
9
  }
10
10
  export declare class RouterResponseController {
11
11
  private readonly applicationRef;