@nestjs/core 7.6.11 → 7.6.15

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
@@ -37,6 +37,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
37
37
 
38
38
  * To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https://docs.nestjs.com). :books:
39
39
  * 要查看中文 [指南](readme_zh.md), 请访问 [docs.nestjs.cn](https://docs.nestjs.cn). :books:
40
+ * [가이드](readme_kr.md)를 확인하려면, [docs.nestjs.com](https://docs.nestjs.com)를 방문하세요.:books:
40
41
 
41
42
  ## Questions
42
43
 
@@ -95,11 +96,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
95
96
  <td align="center" valign="middle">
96
97
  <a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
97
98
  <td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
98
- <td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
99
- <td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
100
99
  <td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
101
- <td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
102
- <td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
100
+ <td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td></tr><tr>
101
+ <td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
102
+ <td align="center" valign="middle"><a href="https://houseofangular.io/" target="_blank"><img src="https://nestjs.com/img/house-of-angular.png" width="100" valign="middle" /></a></td>
103
+ <td align="center" valign="middle"><a href="https://rocketech.it/cases/?utm_source=google&utm_medium=badge&utm_campaign=nestjs" target="_blank"><img src="https://nestjs.com/img/rocketech-logo.svg" width="110" valign="middle" /></a></td>
103
104
  </tr></table>
104
105
 
105
106
  ## Backers
@@ -6,7 +6,13 @@ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
6
6
  * Returns the name of an instance
7
7
  * @param instance The instance which should get the name from
8
8
  */
9
- const getInstanceName = (instance) => instance && instance.name;
9
+ const getInstanceName = (instance) => {
10
+ var _a, _b, _c;
11
+ if ((_a = instance) === null || _a === void 0 ? void 0 : _a.forwardRef) {
12
+ return (_b = instance.forwardRef()) === null || _b === void 0 ? void 0 : _b.name;
13
+ }
14
+ return (_c = instance) === null || _c === void 0 ? void 0 : _c.name;
15
+ };
10
16
  /**
11
17
  * Returns the name of the dependency
12
18
  * Tries to get the class name, otherwise the string value
@@ -19,8 +19,8 @@ class RoutesMapper {
19
19
  },
20
20
  ];
21
21
  }
22
- const routePath = Reflect.getMetadata(constants_1.PATH_METADATA, route);
23
- if (this.isRouteInfo(routePath, route)) {
22
+ const routePathOrPaths = Reflect.getMetadata(constants_1.PATH_METADATA, route);
23
+ if (this.isRouteInfo(routePathOrPaths, route)) {
24
24
  return [
25
25
  {
26
26
  path: this.validateRoutePath(route.path),
@@ -30,12 +30,16 @@ class RoutesMapper {
30
30
  }
31
31
  const paths = this.routerExplorer.scanForPaths(Object.create(route), route.prototype);
32
32
  const concatPaths = (acc, currentValue) => acc.concat(currentValue);
33
- return paths
33
+ return []
34
+ .concat(routePathOrPaths)
35
+ .map(routePath => paths
34
36
  .map(item => item.path &&
35
37
  item.path.map(p => ({
36
- path: this.validateGlobalPath(routePath) + this.validateRoutePath(p),
38
+ path: this.validateGlobalPath(routePath) +
39
+ this.validateRoutePath(p),
37
40
  method: item.requestMethod,
38
41
  })))
42
+ .reduce(concatPaths, []))
39
43
  .reduce(concatPaths, []);
40
44
  }
41
45
  isRouteInfo(path, objectOrClass) {
@@ -4,7 +4,7 @@ declare type RouteInfoRegex = RouteInfo & {
4
4
  };
5
5
  export declare const filterMiddleware: <T extends Function | Type<any> = any>(middleware: T[], excludedRoutes: RouteInfo[], httpAdapter: HttpServer) => Type<any>[];
6
6
  export declare const mapToClass: <T extends Function | Type<any>>(middleware: T, excludedRoutes: RouteInfoRegex[], httpAdapter: HttpServer) => Type<any>;
7
- export declare function isClass(middleware: any): middleware is Type<any>;
7
+ export declare function isMiddlewareClass(middleware: any): middleware is Type<any>;
8
8
  export declare function assignToken(metatype: Type<any>, token?: any): Type<any>;
9
9
  export declare function isRouteExcluded(req: Record<string, any>, excludedRoutes: RouteInfoRegex[], httpAdapter: HttpServer): boolean;
10
10
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRouteExcluded = exports.assignToken = exports.isClass = exports.mapToClass = exports.filterMiddleware = void 0;
3
+ exports.isRouteExcluded = exports.assignToken = exports.isMiddlewareClass = exports.mapToClass = exports.filterMiddleware = void 0;
4
4
  /* eslint-disable @typescript-eslint/no-use-before-define */
5
5
  const common_1 = require("@nestjs/common");
6
6
  const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
@@ -17,7 +17,7 @@ const filterMiddleware = (middleware, excludedRoutes, httpAdapter) => {
17
17
  };
18
18
  exports.filterMiddleware = filterMiddleware;
19
19
  const mapToClass = (middleware, excludedRoutes, httpAdapter) => {
20
- if (isClass(middleware)) {
20
+ if (isMiddlewareClass(middleware)) {
21
21
  if (excludedRoutes.length <= 0) {
22
22
  return middleware;
23
23
  }
@@ -47,10 +47,18 @@ const mapToClass = (middleware, excludedRoutes, httpAdapter) => {
47
47
  });
48
48
  };
49
49
  exports.mapToClass = mapToClass;
50
- function isClass(middleware) {
51
- return middleware.toString().substring(0, 5) === 'class';
50
+ function isMiddlewareClass(middleware) {
51
+ var _a, _b;
52
+ const middlewareStr = middleware.toString();
53
+ if (middlewareStr.substring(0, 5) === 'class') {
54
+ return true;
55
+ }
56
+ const middlewareArr = middlewareStr.split(' ');
57
+ return (middlewareArr[0] === 'function' &&
58
+ /[A-Z]/.test((_a = middlewareArr[1]) === null || _a === void 0 ? void 0 : _a[0]) &&
59
+ typeof ((_b = middleware.prototype) === null || _b === void 0 ? void 0 : _b.use) === 'function');
52
60
  }
53
- exports.isClass = isClass;
61
+ exports.isMiddlewareClass = isMiddlewareClass;
54
62
  function assignToken(metatype, token = uuid_1.v4()) {
55
63
  Object.defineProperty(metatype, 'name', { value: token });
56
64
  return metatype;
package/nest-factory.js CHANGED
@@ -148,14 +148,27 @@ class NestFactoryStatic {
148
148
  : !(serverOrOptions && serverOrOptions.abortOnError === false);
149
149
  }
150
150
  createAdapterProxy(app, adapter) {
151
- return new Proxy(app, {
151
+ const proxy = new Proxy(app, {
152
152
  get: (receiver, prop) => {
153
153
  if (!(prop in receiver) && prop in adapter) {
154
- return this.createExceptionZone(adapter, prop);
154
+ return (...args) => {
155
+ this.createExceptionZone(adapter, prop)(...args);
156
+ return proxy;
157
+ };
158
+ }
159
+ if (shared_utils_1.isFunction(receiver[prop])) {
160
+ const mapToProxy = (result) => result instanceof nest_application_1.NestApplication ? proxy : result;
161
+ return (...args) => {
162
+ const result = receiver[prop](...args);
163
+ return result instanceof Promise
164
+ ? result.then(mapToProxy)
165
+ : mapToProxy(result);
166
+ };
155
167
  }
156
168
  return receiver[prop];
157
169
  },
158
170
  });
171
+ return proxy;
159
172
  }
160
173
  }
161
174
  exports.NestFactoryStatic = NestFactoryStatic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/core",
3
- "version": "7.6.11",
3
+ "version": "7.6.15",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@core)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "uuid": "8.3.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@nestjs/common": "7.6.11"
39
+ "@nestjs/common": "7.6.15"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@nestjs/common": "^7.0.0",
@@ -153,7 +153,7 @@ class RouterExecutionContext {
153
153
  const renderTemplate = this.reflectRenderTemplate(callback);
154
154
  if (renderTemplate) {
155
155
  return async (result, res) => {
156
- await this.responseController.render(result, res, renderTemplate);
156
+ return await this.responseController.render(result, res, renderTemplate);
157
157
  };
158
158
  }
159
159
  if (redirectResponse && typeof redirectResponse.url === 'string') {
@@ -58,19 +58,20 @@ class RouterExplorer {
58
58
  return this.metadataScanner.scanFromPrototype(instance, instancePrototype, method => this.exploreMethodMetadata(instance, instancePrototype, method));
59
59
  }
60
60
  exploreMethodMetadata(instance, prototype, methodName) {
61
- const targetCallback = prototype[methodName];
62
- const routePath = Reflect.getMetadata(constants_1.PATH_METADATA, targetCallback);
61
+ const instanceCallback = instance[methodName];
62
+ const prototypeCallback = prototype[methodName];
63
+ const routePath = Reflect.getMetadata(constants_1.PATH_METADATA, prototypeCallback);
63
64
  if (shared_utils_1.isUndefined(routePath)) {
64
65
  return null;
65
66
  }
66
- const requestMethod = Reflect.getMetadata(constants_1.METHOD_METADATA, targetCallback);
67
+ const requestMethod = Reflect.getMetadata(constants_1.METHOD_METADATA, prototypeCallback);
67
68
  const path = shared_utils_1.isString(routePath)
68
69
  ? [shared_utils_1.addLeadingSlash(routePath)]
69
70
  : routePath.map(p => shared_utils_1.addLeadingSlash(p));
70
71
  return {
71
72
  path,
72
73
  requestMethod,
73
- targetCallback,
74
+ targetCallback: instanceCallback,
74
75
  methodName,
75
76
  };
76
77
  }
@@ -16,7 +16,7 @@ export declare class RouterResponseController {
16
16
  constructor(applicationRef: HttpServer);
17
17
  apply<TInput = any, TResponse = any>(result: TInput, response: TResponse, httpStatusCode?: number): Promise<any>;
18
18
  redirect<TInput = any, TResponse = any>(resultOrDeferred: TInput, response: TResponse, redirectResponse: RedirectResponse): Promise<void>;
19
- render<TInput = unknown, TResponse = unknown>(resultOrDeferred: TInput, response: TResponse, template: string): Promise<void>;
19
+ render<TInput = unknown, TResponse = unknown>(resultOrDeferred: TInput, response: TResponse, template: string): Promise<any>;
20
20
  transformToResult(resultOrDeferred: any): Promise<any>;
21
21
  getStatusByMethod(requestMethod: RequestMethod): number;
22
22
  setHeaders<TResponse = unknown>(response: TResponse, headers: CustomHeader[]): void;
@@ -24,7 +24,7 @@ class RouterResponseController {
24
24
  }
25
25
  async render(resultOrDeferred, response, template) {
26
26
  const result = await this.transformToResult(resultOrDeferred);
27
- this.applicationRef.render(response, template, result);
27
+ return this.applicationRef.render(response, template, result);
28
28
  }
29
29
  async transformToResult(resultOrDeferred) {
30
30
  if (resultOrDeferred && shared_utils_1.isFunction(resultOrDeferred.subscribe)) {