@nestjs/core 8.2.6 → 8.3.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.
Files changed (79) hide show
  1. package/Readme.md +6 -1
  2. package/adapters/index.js +1 -1
  3. package/discovery/discovery-module.js +2 -2
  4. package/discovery/discovery-service.js +5 -5
  5. package/discovery/index.js +2 -2
  6. package/errors/exceptions/invalid-class-module.exception.js +1 -1
  7. package/errors/exceptions/invalid-class-scope.exception.js +2 -2
  8. package/errors/exceptions/invalid-class.exception.js +1 -1
  9. package/errors/exceptions/invalid-middleware.exception.js +1 -1
  10. package/errors/exceptions/invalid-module.exception.js +1 -1
  11. package/errors/exceptions/undefined-dependency.exception.js +1 -1
  12. package/errors/exceptions/undefined-forwardref.exception.js +1 -1
  13. package/errors/exceptions/undefined-module.exception.js +1 -1
  14. package/errors/exceptions/unknown-dependencies.exception.js +1 -1
  15. package/errors/exceptions/unknown-export.exception.js +1 -1
  16. package/errors/messages.js +3 -3
  17. package/exceptions/base-exception-filter-context.js +3 -3
  18. package/exceptions/base-exception-filter.js +6 -6
  19. package/exceptions/exceptions-handler.js +1 -1
  20. package/exceptions/external-exception-filter-context.js +2 -2
  21. package/exceptions/external-exceptions-handler.js +1 -1
  22. package/exceptions/index.js +1 -1
  23. package/guards/guards-consumer.js +2 -2
  24. package/guards/guards-context-creator.js +4 -4
  25. package/helpers/context-utils.js +8 -4
  26. package/helpers/external-context-creator.js +3 -3
  27. package/helpers/index.js +2 -2
  28. package/helpers/interfaces/index.js +2 -2
  29. package/hooks/before-app-shutdown.hook.js +5 -5
  30. package/hooks/index.js +5 -5
  31. package/hooks/on-app-bootstrap.hook.js +5 -5
  32. package/hooks/on-app-shutdown.hook.js +5 -5
  33. package/hooks/on-module-destroy.hook.js +5 -5
  34. package/hooks/on-module-init.hook.js +5 -5
  35. package/index.js +12 -12
  36. package/injector/compiler.js +1 -1
  37. package/injector/helpers/transient-instances.js +2 -2
  38. package/injector/index.js +5 -5
  39. package/injector/injector.js +13 -13
  40. package/injector/inquirer/index.js +1 -1
  41. package/injector/instance-links-host.js +1 -1
  42. package/injector/instance-loader.js +1 -1
  43. package/injector/instance-wrapper.js +7 -7
  44. package/injector/internal-core-module.js +3 -3
  45. package/injector/module-ref.js +1 -1
  46. package/injector/module-token-factory.js +4 -4
  47. package/injector/module.js +18 -18
  48. package/injector/modules-container.js +1 -1
  49. package/interceptors/interceptors-consumer.js +4 -4
  50. package/interceptors/interceptors-context-creator.js +4 -4
  51. package/metadata-scanner.js +4 -4
  52. package/middleware/builder.js +3 -3
  53. package/middleware/container.d.ts +0 -1
  54. package/middleware/container.js +2 -6
  55. package/middleware/index.js +1 -1
  56. package/middleware/middleware-module.js +6 -6
  57. package/middleware/routes-mapper.js +6 -6
  58. package/middleware/utils.js +6 -6
  59. package/nest-application-context.js +8 -8
  60. package/nest-application.js +13 -13
  61. package/nest-factory.js +6 -6
  62. package/package.json +2 -2
  63. package/pipes/pipes-context-creator.js +4 -4
  64. package/router/index.js +2 -2
  65. package/router/interfaces/index.js +1 -1
  66. package/router/route-path-factory.js +8 -8
  67. package/router/router-exception-filters.js +2 -2
  68. package/router/router-execution-context.js +4 -4
  69. package/router/router-explorer.js +12 -12
  70. package/router/router-module.js +6 -6
  71. package/router/router-response-controller.js +6 -6
  72. package/router/routes-resolver.js +6 -3
  73. package/router/sse-stream.js +2 -2
  74. package/router/utils/exclude-route.util.js +1 -1
  75. package/router/utils/flatten-route-paths.util.js +2 -2
  76. package/router/utils/index.js +2 -2
  77. package/scanner.js +9 -9
  78. package/services/index.js +1 -1
  79. package/services/reflector.service.js +2 -2
@@ -12,11 +12,11 @@ class RoutesMapper {
12
12
  this.routerExplorer = new router_explorer_1.RouterExplorer(new metadata_scanner_1.MetadataScanner(), container);
13
13
  }
14
14
  mapRouteToRouteInfo(route) {
15
- if (shared_utils_1.isString(route)) {
15
+ if ((0, shared_utils_1.isString)(route)) {
16
16
  const defaultRequestMethod = -1;
17
17
  return [
18
18
  {
19
- path: shared_utils_1.addLeadingSlash(route),
19
+ path: (0, shared_utils_1.addLeadingSlash)(route),
20
20
  method: defaultRequestMethod,
21
21
  },
22
22
  ];
@@ -25,7 +25,7 @@ class RoutesMapper {
25
25
  if (this.isRouteInfo(routePathOrPaths, route)) {
26
26
  return [
27
27
  {
28
- path: shared_utils_1.addLeadingSlash(route.path),
28
+ path: (0, shared_utils_1.addLeadingSlash)(route.path),
29
29
  method: route.method,
30
30
  },
31
31
  ];
@@ -41,7 +41,7 @@ class RoutesMapper {
41
41
  var _a;
42
42
  return (_a = item.path) === null || _a === void 0 ? void 0 : _a.map(p => {
43
43
  let path = modulePath !== null && modulePath !== void 0 ? modulePath : '';
44
- path += this.normalizeGlobalPath(routePath) + shared_utils_1.addLeadingSlash(p);
44
+ path += this.normalizeGlobalPath(routePath) + (0, shared_utils_1.addLeadingSlash)(p);
45
45
  return {
46
46
  path,
47
47
  method: item.requestMethod,
@@ -52,10 +52,10 @@ class RoutesMapper {
52
52
  .reduce(concatPaths, []);
53
53
  }
54
54
  isRouteInfo(path, objectOrClass) {
55
- return shared_utils_1.isUndefined(path);
55
+ return (0, shared_utils_1.isUndefined)(path);
56
56
  }
57
57
  normalizeGlobalPath(path) {
58
- const prefix = shared_utils_1.addLeadingSlash(path);
58
+ const prefix = (0, shared_utils_1.addLeadingSlash)(path);
59
59
  return prefix === '/' ? '' : prefix;
60
60
  }
61
61
  getRoutePath(route) {
@@ -15,11 +15,11 @@ const mapToExcludeRoute = (routes) => {
15
15
  };
16
16
  exports.mapToExcludeRoute = mapToExcludeRoute;
17
17
  const filterMiddleware = (middleware, routes, httpAdapter) => {
18
- const excludedRoutes = exports.mapToExcludeRoute(routes);
19
- return iterare_1.iterate([])
18
+ const excludedRoutes = (0, exports.mapToExcludeRoute)(routes);
19
+ return (0, iterare_1.iterate)([])
20
20
  .concat(middleware)
21
21
  .filter(shared_utils_1.isFunction)
22
- .map((item) => exports.mapToClass(item, excludedRoutes, httpAdapter))
22
+ .map((item) => (0, exports.mapToClass)(item, excludedRoutes, httpAdapter))
23
23
  .toArray();
24
24
  };
25
25
  exports.filterMiddleware = filterMiddleware;
@@ -63,10 +63,10 @@ function isMiddlewareClass(middleware) {
63
63
  const middlewareArr = middlewareStr.split(' ');
64
64
  return (middlewareArr[0] === 'function' &&
65
65
  /[A-Z]/.test((_a = middlewareArr[1]) === null || _a === void 0 ? void 0 : _a[0]) &&
66
- shared_utils_1.isFunction((_b = middleware.prototype) === null || _b === void 0 ? void 0 : _b.use));
66
+ (0, shared_utils_1.isFunction)((_b = middleware.prototype) === null || _b === void 0 ? void 0 : _b.use));
67
67
  }
68
68
  exports.isMiddlewareClass = isMiddlewareClass;
69
- function assignToken(metatype, token = uuid_1.v4()) {
69
+ function assignToken(metatype, token = (0, uuid_1.v4)()) {
70
70
  Object.defineProperty(metatype, 'name', { value: token });
71
71
  return metatype;
72
72
  }
@@ -81,6 +81,6 @@ function isMiddlewareRouteExcluded(req, excludedRoutes, httpAdapter) {
81
81
  const pathname = queryParamsIndex >= 0
82
82
  ? originalUrl.slice(0, queryParamsIndex)
83
83
  : originalUrl;
84
- return utils_1.isRouteExcluded(excludedRoutes, pathname, common_1.RequestMethod[reqMethod]);
84
+ return (0, utils_1.isRouteExcluded)(excludedRoutes, pathname, common_1.RequestMethod[reqMethod]);
85
85
  }
86
86
  exports.isMiddlewareRouteExcluded = isMiddlewareRouteExcluded;
@@ -56,7 +56,7 @@ class NestApplicationContext {
56
56
  ? this.find(typeOrToken)
57
57
  : this.find(typeOrToken, this.contextModule);
58
58
  }
59
- resolve(typeOrToken, contextId = context_id_factory_1.createContextId(), options = { strict: false }) {
59
+ resolve(typeOrToken, contextId = (0, context_id_factory_1.createContextId)(), options = { strict: false }) {
60
60
  return this.resolvePerContext(typeOrToken, this.contextModule, contextId, options);
61
61
  }
62
62
  registerRequestByContextId(request, contextId) {
@@ -109,7 +109,7 @@ class NestApplicationContext {
109
109
  * @returns {this} The Nest application context instance
110
110
  */
111
111
  enableShutdownHooks(signals = []) {
112
- if (shared_utils_1.isEmpty(signals)) {
112
+ if ((0, shared_utils_1.isEmpty)(signals)) {
113
113
  signals = Object.keys(common_1.ShutdownSignal).map((key) => common_1.ShutdownSignal[key]);
114
114
  }
115
115
  else {
@@ -117,7 +117,7 @@ class NestApplicationContext {
117
117
  // process shouldn't listen to the same signal more than once.
118
118
  signals = Array.from(new Set(signals));
119
119
  }
120
- signals = iterare_1.iterate(signals)
120
+ signals = (0, iterare_1.iterate)(signals)
121
121
  .map((signal) => signal.toString().toUpperCase().trim())
122
122
  // filter out the signals which is already listening to
123
123
  .filter(signal => !this.activeShutdownSignals.includes(signal))
@@ -176,7 +176,7 @@ class NestApplicationContext {
176
176
  async callInitHook() {
177
177
  const modulesSortedByDistance = this.getModulesSortedByDistance();
178
178
  for (const module of modulesSortedByDistance) {
179
- await hooks_1.callModuleInitHook(module);
179
+ await (0, hooks_1.callModuleInitHook)(module);
180
180
  }
181
181
  }
182
182
  /**
@@ -186,7 +186,7 @@ class NestApplicationContext {
186
186
  async callDestroyHook() {
187
187
  const modulesSortedByDistance = this.getModulesSortedByDistance();
188
188
  for (const module of modulesSortedByDistance) {
189
- await hooks_1.callModuleDestroyHook(module);
189
+ await (0, hooks_1.callModuleDestroyHook)(module);
190
190
  }
191
191
  }
192
192
  /**
@@ -196,7 +196,7 @@ class NestApplicationContext {
196
196
  async callBootstrapHook() {
197
197
  const modulesSortedByDistance = this.getModulesSortedByDistance();
198
198
  for (const module of modulesSortedByDistance) {
199
- await hooks_1.callModuleBootstrapHook(module);
199
+ await (0, hooks_1.callModuleBootstrapHook)(module);
200
200
  }
201
201
  }
202
202
  /**
@@ -206,7 +206,7 @@ class NestApplicationContext {
206
206
  async callShutdownHook(signal) {
207
207
  const modulesSortedByDistance = this.getModulesSortedByDistance();
208
208
  for (const module of modulesSortedByDistance) {
209
- await hooks_1.callAppShutdownHook(module, signal);
209
+ await (0, hooks_1.callAppShutdownHook)(module, signal);
210
210
  }
211
211
  }
212
212
  /**
@@ -216,7 +216,7 @@ class NestApplicationContext {
216
216
  async callBeforeShutdownHook(signal) {
217
217
  const modulesSortedByDistance = this.getModulesSortedByDistance();
218
218
  for (const module of modulesSortedByDistance) {
219
- await hooks_1.callBeforeAppShutdownHook(module, signal);
219
+ await (0, hooks_1.callBeforeAppShutdownHook)(module, signal);
220
220
  }
221
221
  }
222
222
  find(typeOrToken, contextModule) {
@@ -15,8 +15,8 @@ const container_1 = require("./middleware/container");
15
15
  const middleware_module_1 = require("./middleware/middleware-module");
16
16
  const nest_application_context_1 = require("./nest-application-context");
17
17
  const routes_resolver_1 = require("./router/routes-resolver");
18
- const { SocketModule } = optional_require_1.optionalRequire('@nestjs/websockets/socket-module', () => require('@nestjs/websockets/socket-module'));
19
- const { MicroservicesModule } = optional_require_1.optionalRequire('@nestjs/microservices/microservices-module', () => require('@nestjs/microservices/microservices-module'));
18
+ const { SocketModule } = (0, optional_require_1.optionalRequire)('@nestjs/websockets/socket-module', () => require('@nestjs/websockets/socket-module'));
19
+ const { MicroservicesModule } = (0, optional_require_1.optionalRequire)('@nestjs/microservices/microservices-module', () => require('@nestjs/microservices/microservices-module'));
20
20
  /**
21
21
  * @publicApi
22
22
  */
@@ -43,7 +43,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
43
43
  this.socketModule && (await this.socketModule.close());
44
44
  this.microservicesModule && (await this.microservicesModule.close());
45
45
  this.httpAdapter && (await this.httpAdapter.close());
46
- await Promise.all(iterare_1.iterate(this.microservices).map(async (microservice) => {
46
+ await Promise.all((0, iterare_1.iterate)(this.microservices).map(async (microservice) => {
47
47
  microservice.setIsTerminated(true);
48
48
  await microservice.close();
49
49
  }));
@@ -61,7 +61,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
61
61
  if (!this.appOptions || !this.appOptions.cors) {
62
62
  return undefined;
63
63
  }
64
- const passCustomOptions = shared_utils_1.isObject(this.appOptions.cors) || shared_utils_1.isFunction(this.appOptions.cors);
64
+ const passCustomOptions = (0, shared_utils_1.isObject)(this.appOptions.cors) || (0, shared_utils_1.isFunction)(this.appOptions.cors);
65
65
  if (!passCustomOptions) {
66
66
  return this.enableCors();
67
67
  }
@@ -106,7 +106,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
106
106
  async registerRouter() {
107
107
  await this.registerMiddleware(this.httpAdapter);
108
108
  const prefix = this.config.getGlobalPrefix();
109
- const basePath = shared_utils_1.addLeadingSlash(prefix);
109
+ const basePath = (0, shared_utils_1.addLeadingSlash)(prefix);
110
110
  this.routesResolver.resolve(this.httpAdapter, basePath);
111
111
  }
112
112
  async registerRouterHooks() {
@@ -114,7 +114,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
114
114
  this.routesResolver.registerExceptionHandler();
115
115
  }
116
116
  connectMicroservice(microserviceOptions, hybridAppOptions = {}) {
117
- const { NestMicroservice } = load_package_util_1.loadPackage('@nestjs/microservices', 'NestFactory', () => require('@nestjs/microservices'));
117
+ const { NestMicroservice } = (0, load_package_util_1.loadPackage)('@nestjs/microservices', 'NestFactory', () => require('@nestjs/microservices'));
118
118
  const { inheritAppConfig } = hybridAppOptions;
119
119
  const applicationConfig = inheritAppConfig
120
120
  ? this.config
@@ -160,7 +160,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
160
160
  reject(e);
161
161
  };
162
162
  this.httpServer.once('error', errorHandler);
163
- const isCallbackInOriginalArgs = shared_utils_1.isFunction(args[args.length - 1]);
163
+ const isCallbackInOriginalArgs = (0, shared_utils_1.isFunction)(args[args.length - 1]);
164
164
  const listenFnArgs = isCallbackInOriginalArgs
165
165
  ? args.slice(0, args.length - 1)
166
166
  : args;
@@ -199,8 +199,8 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
199
199
  });
200
200
  }
201
201
  formatAddress(address) {
202
- if (shared_utils_1.isString(address)) {
203
- if (os_1.platform() === 'win32') {
202
+ if ((0, shared_utils_1.isString)(address)) {
203
+ if ((0, os_1.platform)() === 'win32') {
204
204
  return address;
205
205
  }
206
206
  const basePath = encodeURIComponent(address);
@@ -224,15 +224,15 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
224
224
  this.config.setGlobalPrefix(prefix);
225
225
  if (options) {
226
226
  const exclude = options === null || options === void 0 ? void 0 : options.exclude.map((route) => {
227
- if (shared_utils_1.isString(route)) {
227
+ if ((0, shared_utils_1.isString)(route)) {
228
228
  return {
229
229
  requestMethod: common_1.RequestMethod.ALL,
230
- pathRegex: pathToRegexp(shared_utils_1.addLeadingSlash(route)),
230
+ pathRegex: pathToRegexp((0, shared_utils_1.addLeadingSlash)(route)),
231
231
  };
232
232
  }
233
233
  return {
234
234
  requestMethod: route.method,
235
- pathRegex: pathToRegexp(shared_utils_1.addLeadingSlash(route.path)),
235
+ pathRegex: pathToRegexp((0, shared_utils_1.addLeadingSlash)(route.path)),
236
236
  };
237
237
  });
238
238
  this.config.setGlobalPrefixOptions(Object.assign(Object.assign({}, options), { exclude }));
@@ -275,7 +275,7 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
275
275
  }
276
276
  host() {
277
277
  const address = this.httpServer.address();
278
- if (shared_utils_1.isString(address)) {
278
+ if ((0, shared_utils_1.isString)(address)) {
279
279
  return undefined;
280
280
  }
281
281
  return address && address.address;
package/nest-factory.js CHANGED
@@ -49,7 +49,7 @@ class NestFactoryStatic {
49
49
  * contains a reference to the NestMicroservice instance.
50
50
  */
51
51
  async createMicroservice(module, options) {
52
- const { NestMicroservice } = load_package_util_1.loadPackage('@nestjs/microservices', 'NestFactory', () => require('@nestjs/microservices'));
52
+ const { NestMicroservice } = (0, load_package_util_1.loadPackage)('@nestjs/microservices', 'NestFactory', () => require('@nestjs/microservices'));
53
53
  const applicationConfig = new application_config_1.ApplicationConfig();
54
54
  const container = new container_1.NestContainer(applicationConfig);
55
55
  this.setAbortOnError(options);
@@ -105,7 +105,7 @@ class NestFactoryStatic {
105
105
  if (this.abortOnError) {
106
106
  process.abort();
107
107
  }
108
- rethrow_1.rethrow(err);
108
+ (0, rethrow_1.rethrow)(err);
109
109
  }
110
110
  createProxy(target) {
111
111
  const proxy = this.createExceptionProxy();
@@ -119,7 +119,7 @@ class NestFactoryStatic {
119
119
  if (!(prop in receiver)) {
120
120
  return;
121
121
  }
122
- if (shared_utils_1.isFunction(receiver[prop])) {
122
+ if ((0, shared_utils_1.isFunction)(receiver[prop])) {
123
123
  return this.createExceptionZone(receiver, prop);
124
124
  }
125
125
  return receiver[prop];
@@ -140,7 +140,7 @@ class NestFactoryStatic {
140
140
  return;
141
141
  }
142
142
  const { logger, bufferLogs, autoFlushLogs } = options;
143
- if (logger !== true && !shared_utils_1.isNil(logger)) {
143
+ if (logger !== true && !(0, shared_utils_1.isNil)(logger)) {
144
144
  logger_service_1.Logger.overrideLogger(logger);
145
145
  }
146
146
  if (bufferLogs) {
@@ -149,7 +149,7 @@ class NestFactoryStatic {
149
149
  this.autoFlushLogs = autoFlushLogs !== null && autoFlushLogs !== void 0 ? autoFlushLogs : true;
150
150
  }
151
151
  createHttpAdapter(httpServer) {
152
- const { ExpressAdapter } = load_adapter_1.loadAdapter('@nestjs/platform-express', 'HTTP', () => require('@nestjs/platform-express'));
152
+ const { ExpressAdapter } = (0, load_adapter_1.loadAdapter)('@nestjs/platform-express', 'HTTP', () => require('@nestjs/platform-express'));
153
153
  return new ExpressAdapter(httpServer);
154
154
  }
155
155
  isHttpServer(serverOrOptions) {
@@ -176,7 +176,7 @@ class NestFactoryStatic {
176
176
  return mapToProxy(result);
177
177
  };
178
178
  }
179
- if (shared_utils_1.isFunction(receiver[prop])) {
179
+ if ((0, shared_utils_1.isFunction)(receiver[prop])) {
180
180
  return (...args) => {
181
181
  const result = receiver[prop](...args);
182
182
  return mapToProxy(result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/core",
3
- "version": "8.2.6",
3
+ "version": "8.3.0",
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": "8.2.6"
39
+ "@nestjs/common": "8.3.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@nestjs/common": "^8.0.0",
@@ -17,13 +17,13 @@ class PipesContextCreator extends context_creator_1.ContextCreator {
17
17
  return this.createContext(instance, callback, constants_1.PIPES_METADATA, contextId, inquirerId);
18
18
  }
19
19
  createConcreteContext(metadata, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
20
- if (shared_utils_1.isEmpty(metadata)) {
20
+ if ((0, shared_utils_1.isEmpty)(metadata)) {
21
21
  return [];
22
22
  }
23
- return iterare_1.iterate(metadata)
23
+ return (0, iterare_1.iterate)(metadata)
24
24
  .filter((pipe) => pipe && (pipe.name || pipe.transform))
25
25
  .map(pipe => this.getPipeInstance(pipe, contextId, inquirerId))
26
- .filter(pipe => pipe && pipe.transform && shared_utils_1.isFunction(pipe.transform))
26
+ .filter(pipe => pipe && pipe.transform && (0, shared_utils_1.isFunction)(pipe.transform))
27
27
  .toArray();
28
28
  }
29
29
  getPipeInstance(pipe, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
@@ -58,7 +58,7 @@ class PipesContextCreator extends context_creator_1.ContextCreator {
58
58
  return globalPipes;
59
59
  }
60
60
  const scopedPipeWrappers = this.config.getGlobalRequestPipes();
61
- const scopedPipes = iterare_1.iterate(scopedPipeWrappers)
61
+ const scopedPipes = (0, iterare_1.iterate)(scopedPipeWrappers)
62
62
  .map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
63
63
  .filter(host => !!host)
64
64
  .map(host => host.instance)
package/router/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RouterModule = void 0;
4
4
  const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./interfaces"), exports);
6
- tslib_1.__exportStar(require("./request"), exports);
5
+ (0, tslib_1.__exportStar)(require("./interfaces"), exports);
6
+ (0, tslib_1.__exportStar)(require("./request"), exports);
7
7
  var router_module_1 = require("./router-module");
8
8
  Object.defineProperty(exports, "RouterModule", { enumerable: true, get: function () { return router_module_1.RouterModule; } });
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./routes.interface"), exports);
4
+ (0, tslib_1.__exportStar)(require("./routes.interface"), exports);
@@ -16,7 +16,7 @@ class RoutePathFactory {
16
16
  ((_a = metadata.versioningOptions) === null || _a === void 0 ? void 0 : _a.type) === common_1.VersioningType.URI) {
17
17
  const versionPrefix = this.getVersionPrefix(metadata.versioningOptions);
18
18
  if (Array.isArray(versionOrVersions)) {
19
- paths = common_1.flatten(paths.map(path => versionOrVersions.map(version =>
19
+ paths = (0, common_1.flatten)(paths.map(path => versionOrVersions.map(version =>
20
20
  // Version Neutral - Do not include version in URL
21
21
  version === common_1.VERSION_NEUTRAL
22
22
  ? path
@@ -37,12 +37,12 @@ class RoutePathFactory {
37
37
  if (this.isExcludedFromGlobalPrefix(path, requestMethod)) {
38
38
  return path;
39
39
  }
40
- return shared_utils_1.stripEndSlash(metadata.globalPrefix || '') + path;
40
+ return (0, shared_utils_1.stripEndSlash)(metadata.globalPrefix || '') + path;
41
41
  });
42
42
  }
43
43
  return paths
44
- .map(path => shared_utils_1.addLeadingSlash(path || '/'))
45
- .map(path => (path !== '/' ? shared_utils_1.stripEndSlash(path) : path));
44
+ .map(path => (0, shared_utils_1.addLeadingSlash)(path || '/'))
45
+ .map(path => (path !== '/' ? (0, shared_utils_1.stripEndSlash)(path) : path));
46
46
  }
47
47
  getVersion(metadata) {
48
48
  // The version will be either the path version or the controller version,
@@ -65,21 +65,21 @@ class RoutePathFactory {
65
65
  if (!fragmentToAppend) {
66
66
  return paths;
67
67
  }
68
- const concatPaths = (a, b) => shared_utils_1.stripEndSlash(a) + shared_utils_1.addLeadingSlash(b);
68
+ const concatPaths = (a, b) => (0, shared_utils_1.stripEndSlash)(a) + (0, shared_utils_1.addLeadingSlash)(b);
69
69
  if (Array.isArray(fragmentToAppend)) {
70
70
  const paths2dArray = paths.map(path => fragmentToAppend.map(fragment => concatPaths(path, fragment)));
71
- return common_1.flatten(paths2dArray);
71
+ return (0, common_1.flatten)(paths2dArray);
72
72
  }
73
73
  return paths.map(path => concatPaths(path, fragmentToAppend));
74
74
  }
75
75
  isExcludedFromGlobalPrefix(path, requestMethod) {
76
- if (shared_utils_1.isUndefined(requestMethod)) {
76
+ if ((0, shared_utils_1.isUndefined)(requestMethod)) {
77
77
  return false;
78
78
  }
79
79
  const options = this.applicationConfig.getGlobalPrefixOptions();
80
80
  const excludedRoutes = options.exclude;
81
81
  return (Array.isArray(excludedRoutes) &&
82
- utils_1.isRouteExcluded(excludedRoutes, path, requestMethod));
82
+ (0, utils_1.isRouteExcluded)(excludedRoutes, path, requestMethod));
83
83
  }
84
84
  }
85
85
  exports.RoutePathFactory = RoutePathFactory;
@@ -17,7 +17,7 @@ class RouterExceptionFilters extends base_exception_filter_context_1.BaseExcepti
17
17
  this.moduleContext = moduleKey;
18
18
  const exceptionHandler = new exceptions_handler_1.ExceptionsHandler(this.applicationRef);
19
19
  const filters = this.createContext(instance, callback, constants_1.EXCEPTION_FILTERS_METADATA, contextId, inquirerId);
20
- if (shared_utils_1.isEmpty(filters)) {
20
+ if ((0, shared_utils_1.isEmpty)(filters)) {
21
21
  return exceptionHandler;
22
22
  }
23
23
  exceptionHandler.setCustomFilters(filters.reverse());
@@ -29,7 +29,7 @@ class RouterExceptionFilters extends base_exception_filter_context_1.BaseExcepti
29
29
  return globalFilters;
30
30
  }
31
31
  const scopedFilterWrappers = this.config.getGlobalRequestFilters();
32
- const scopedFilters = iterare_1.iterate(scopedFilterWrappers)
32
+ const scopedFilters = (0, iterare_1.iterate)(scopedFilterWrappers)
33
33
  .map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
34
34
  .filter(host => !!host)
35
35
  .map(host => host.instance)
@@ -67,7 +67,7 @@ class RouterExecutionContext {
67
67
  ? httpCode
68
68
  : this.responseController.getStatusByMethod(requestMethod);
69
69
  const responseHeaders = this.reflectResponseHeaders(callback);
70
- const hasCustomHeaders = !shared_utils_1.isEmpty(responseHeaders);
70
+ const hasCustomHeaders = !(0, shared_utils_1.isEmpty)(responseHeaders);
71
71
  const handlerMetadata = {
72
72
  argsLength,
73
73
  fnHandleResponse,
@@ -116,7 +116,7 @@ class RouterExecutionContext {
116
116
  });
117
117
  }
118
118
  async getParamValue(value, { metatype, type, data, }, pipes) {
119
- if (!shared_utils_1.isEmpty(pipes)) {
119
+ if (!(0, shared_utils_1.isEmpty)(pipes)) {
120
120
  return this.pipesConsumer.apply(value, { metatype, type, data }, pipes);
121
121
  }
122
122
  return value;
@@ -127,7 +127,7 @@ class RouterExecutionContext {
127
127
  type === route_paramtypes_enum_1.RouteParamtypes.PARAM ||
128
128
  type === route_paramtypes_enum_1.RouteParamtypes.FILE ||
129
129
  type === route_paramtypes_enum_1.RouteParamtypes.FILES ||
130
- shared_utils_1.isString(type));
130
+ (0, shared_utils_1.isString)(type));
131
131
  }
132
132
  createGuardsFn(guards, instance, callback, contextType) {
133
133
  const canActivateFn = async (args) => {
@@ -158,7 +158,7 @@ class RouterExecutionContext {
158
158
  return await this.responseController.render(result, res, renderTemplate);
159
159
  };
160
160
  }
161
- if (redirectResponse && shared_utils_1.isString(redirectResponse.url)) {
161
+ if (redirectResponse && (0, shared_utils_1.isString)(redirectResponse.url)) {
162
162
  return async (result, res) => {
163
163
  await this.responseController.redirect(result, res, redirectResponse);
164
164
  };
@@ -53,16 +53,16 @@ class RouterExplorer {
53
53
  }
54
54
  extractRouterPath(metatype) {
55
55
  const path = Reflect.getMetadata(constants_1.PATH_METADATA, metatype);
56
- if (shared_utils_1.isUndefined(path)) {
56
+ if ((0, shared_utils_1.isUndefined)(path)) {
57
57
  throw new unknown_request_mapping_exception_1.UnknownRequestMappingException();
58
58
  }
59
59
  if (Array.isArray(path)) {
60
- return path.map(p => shared_utils_1.addLeadingSlash(p));
60
+ return path.map(p => (0, shared_utils_1.addLeadingSlash)(p));
61
61
  }
62
- return [shared_utils_1.addLeadingSlash(path)];
62
+ return [(0, shared_utils_1.addLeadingSlash)(path)];
63
63
  }
64
64
  scanForPaths(instance, prototype) {
65
- const instancePrototype = shared_utils_1.isUndefined(prototype)
65
+ const instancePrototype = (0, shared_utils_1.isUndefined)(prototype)
66
66
  ? Object.getPrototypeOf(instance)
67
67
  : prototype;
68
68
  return this.metadataScanner.scanFromPrototype(instance, instancePrototype, method => this.exploreMethodMetadata(instance, instancePrototype, method));
@@ -71,14 +71,14 @@ class RouterExplorer {
71
71
  const instanceCallback = instance[methodName];
72
72
  const prototypeCallback = prototype[methodName];
73
73
  const routePath = Reflect.getMetadata(constants_1.PATH_METADATA, prototypeCallback);
74
- if (shared_utils_1.isUndefined(routePath)) {
74
+ if ((0, shared_utils_1.isUndefined)(routePath)) {
75
75
  return null;
76
76
  }
77
77
  const requestMethod = Reflect.getMetadata(constants_1.METHOD_METADATA, prototypeCallback);
78
78
  const version = Reflect.getMetadata(constants_1.VERSION_METADATA, prototypeCallback);
79
- const path = shared_utils_1.isString(routePath)
80
- ? [shared_utils_1.addLeadingSlash(routePath)]
81
- : routePath.map((p) => shared_utils_1.addLeadingSlash(p));
79
+ const path = (0, shared_utils_1.isString)(routePath)
80
+ ? [(0, shared_utils_1.addLeadingSlash)(routePath)]
81
+ : routePath.map((p) => (0, shared_utils_1.addLeadingSlash)(p));
82
82
  return {
83
83
  path,
84
84
  requestMethod,
@@ -121,10 +121,10 @@ class RouterExplorer {
121
121
  pathsToLog.forEach(path => {
122
122
  if (isVersioned) {
123
123
  const version = this.routePathFactory.getVersion(routePathMetadata);
124
- this.logger.log(messages_1.VERSIONED_ROUTE_MAPPED_MESSAGE(path, requestMethod, version));
124
+ this.logger.log((0, messages_1.VERSIONED_ROUTE_MAPPED_MESSAGE)(path, requestMethod, version));
125
125
  }
126
126
  else {
127
- this.logger.log(messages_1.ROUTE_MAPPED_MESSAGE(path, requestMethod));
127
+ this.logger.log((0, messages_1.ROUTE_MAPPED_MESSAGE)(path, requestMethod));
128
128
  }
129
129
  });
130
130
  });
@@ -193,7 +193,7 @@ class RouterExplorer {
193
193
  return handler(req, res, next);
194
194
  }
195
195
  }
196
- else if (shared_utils_1.isString(version)) {
196
+ else if ((0, shared_utils_1.isString)(version)) {
197
197
  if (version === headerVersion) {
198
198
  return handler(req, res, next);
199
199
  }
@@ -210,7 +210,7 @@ class RouterExplorer {
210
210
  return handler(req, res, next);
211
211
  }
212
212
  }
213
- else if (shared_utils_1.isString(version)) {
213
+ else if ((0, shared_utils_1.isString)(version)) {
214
214
  if (version === customHeaderVersionParameter) {
215
215
  return handler(req, res, next);
216
216
  }
@@ -43,9 +43,9 @@ let RouterModule = RouterModule_1 = class RouterModule {
43
43
  });
44
44
  }
45
45
  initialize() {
46
- const flattenedRoutes = utils_1.flattenRoutePaths(this.routes);
46
+ const flattenedRoutes = (0, utils_1.flattenRoutePaths)(this.routes);
47
47
  flattenedRoutes.forEach(route => {
48
- const modulePath = shared_utils_1.normalizePath(route.path);
48
+ const modulePath = (0, shared_utils_1.normalizePath)(route.path);
49
49
  this.registerModulePathMetadata(route.module, modulePath);
50
50
  this.updateTargetModulesCache(route.module);
51
51
  });
@@ -69,9 +69,9 @@ let RouterModule = RouterModule_1 = class RouterModule {
69
69
  moduleClassSet.add(moduleRef);
70
70
  }
71
71
  };
72
- RouterModule = RouterModule_1 = tslib_1.__decorate([
73
- common_1.Module({}),
74
- tslib_1.__param(1, common_1.Inject(exports.ROUTES)),
75
- tslib_1.__metadata("design:paramtypes", [modules_container_1.ModulesContainer, Array])
72
+ RouterModule = RouterModule_1 = (0, tslib_1.__decorate)([
73
+ (0, common_1.Module)({}),
74
+ (0, tslib_1.__param)(1, (0, common_1.Inject)(exports.ROUTES)),
75
+ (0, tslib_1.__metadata)("design:paramtypes", [modules_container_1.ModulesContainer, Array])
76
76
  ], RouterModule);
77
77
  exports.RouterModule = RouterModule;
@@ -29,8 +29,8 @@ class RouterResponseController {
29
29
  return this.applicationRef.render(response, template, result);
30
30
  }
31
31
  async transformToResult(resultOrDeferred) {
32
- if (resultOrDeferred && shared_utils_1.isFunction(resultOrDeferred.subscribe)) {
33
- return rxjs_1.lastValueFrom(resultOrDeferred);
32
+ if (resultOrDeferred && (0, shared_utils_1.isFunction)(resultOrDeferred.subscribe)) {
33
+ return (0, rxjs_1.lastValueFrom)(resultOrDeferred);
34
34
  }
35
35
  return resultOrDeferred;
36
36
  }
@@ -57,12 +57,12 @@ class RouterResponseController {
57
57
  const stream = new sse_stream_1.SseStream(request);
58
58
  stream.pipe(response, options);
59
59
  const subscription = result
60
- .pipe(operators_1.map((message) => {
61
- if (shared_utils_1.isObject(message)) {
60
+ .pipe((0, operators_1.map)((message) => {
61
+ if ((0, shared_utils_1.isObject)(message)) {
62
62
  return message;
63
63
  }
64
64
  return { data: message };
65
- }), operators_1.debounce(message => new Promise(resolve => stream.writeMessage(message, () => resolve()))), operators_1.catchError(err => {
65
+ }), (0, operators_1.debounce)(message => new Promise(resolve => stream.writeMessage(message, () => resolve()))), (0, operators_1.catchError)(err => {
66
66
  const data = err instanceof Error ? err.message : err;
67
67
  stream.writeMessage({ type: 'error', data }, writeError => {
68
68
  if (writeError) {
@@ -81,7 +81,7 @@ class RouterResponseController {
81
81
  });
82
82
  }
83
83
  assertObservable(result) {
84
- if (!shared_utils_1.isFunction(result.subscribe)) {
84
+ if (!(0, shared_utils_1.isFunction)(result.subscribe)) {
85
85
  throw new ReferenceError('You must return an Observable stream to use Server-Sent Events (SSE).');
86
86
  }
87
87
  }
@@ -47,13 +47,13 @@ class RoutesResolver {
47
47
  });
48
48
  if (!controllerVersion) {
49
49
  pathsToLog.forEach(path => {
50
- const logMessage = messages_1.CONTROLLER_MAPPING_MESSAGE(controllerName, path);
50
+ const logMessage = (0, messages_1.CONTROLLER_MAPPING_MESSAGE)(controllerName, path);
51
51
  this.logger.log(logMessage);
52
52
  });
53
53
  }
54
54
  else {
55
55
  pathsToLog.forEach(path => {
56
- const logMessage = messages_1.VERSIONED_CONTROLLER_MAPPING_MESSAGE(controllerName, path, controllerVersion);
56
+ const logMessage = (0, messages_1.VERSIONED_CONTROLLER_MAPPING_MESSAGE)(controllerName, path, controllerVersion);
57
57
  this.logger.log(logMessage);
58
58
  });
59
59
  }
@@ -93,7 +93,10 @@ class RoutesResolver {
93
93
  }
94
94
  mapExternalException(err) {
95
95
  switch (true) {
96
- case err instanceof SyntaxError:
96
+ // SyntaxError is thrown by Express body-parser when given invalid JSON (#422, #430)
97
+ // URIError is thrown by Express when given a path parameter with an invalid percentage
98
+ // encoding, e.g. '%FF' (#8915)
99
+ case err instanceof SyntaxError || err instanceof URIError:
97
100
  return new common_1.BadRequestException(err.message);
98
101
  default:
99
102
  return err;
@@ -4,7 +4,7 @@ exports.SseStream = void 0;
4
4
  const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
5
  const stream_1 = require("stream");
6
6
  function toDataString(data) {
7
- if (shared_utils_1.isObject(data)) {
7
+ if ((0, shared_utils_1.isObject)(data)) {
8
8
  return toDataString(JSON.stringify(data));
9
9
  }
10
10
  return data
@@ -46,7 +46,7 @@ class SseStream extends stream_1.Transform {
46
46
  'X-Accel-Buffering': 'no' }));
47
47
  destination.flushHeaders();
48
48
  }
49
- destination.write(':\n');
49
+ destination.write('\n');
50
50
  return super.pipe(destination, options);
51
51
  }
52
52
  _transform(message, encoding, callback) {