@nestjs/core 11.0.11 → 11.0.12

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.
@@ -48,7 +48,13 @@ class InstanceWrapper {
48
48
  const instancePerContext = this.values.get(contextId);
49
49
  return instancePerContext
50
50
  ? instancePerContext
51
- : this.cloneStaticInstance(contextId);
51
+ : contextId !== constants_1.STATIC_CONTEXT
52
+ ? this.cloneStaticInstance(contextId)
53
+ : {
54
+ instance: null,
55
+ isResolved: true,
56
+ isPending: false,
57
+ };
52
58
  }
53
59
  getInstanceByInquirerId(contextId, inquirerId) {
54
60
  let collectionPerContext = this.transientMap.get(inquirerId);
@@ -78,4 +78,5 @@ export declare class Module {
78
78
  private isEntryProvider;
79
79
  private generateUuid;
80
80
  private isTransientProvider;
81
+ private isRequestScopeProvider;
81
82
  }
@@ -161,7 +161,9 @@ class Module {
161
161
  return this.addCustomProvider(provider, this._providers, enhancerSubtype);
162
162
  }
163
163
  const isAlreadyDeclared = this._providers.has(provider);
164
- if (this.isTransientProvider(provider) && isAlreadyDeclared) {
164
+ if ((this.isTransientProvider(provider) ||
165
+ this.isRequestScopeProvider(provider)) &&
166
+ isAlreadyDeclared) {
165
167
  return provider;
166
168
  }
167
169
  this._providers.set(provider, new instance_wrapper_1.InstanceWrapper({
@@ -422,5 +424,8 @@ class Module {
422
424
  isTransientProvider(provider) {
423
425
  return (0, get_class_scope_1.getClassScope)(provider) === interfaces_1.Scope.TRANSIENT;
424
426
  }
427
+ isRequestScopeProvider(provider) {
428
+ return (0, get_class_scope_1.getClassScope)(provider) === interfaces_1.Scope.REQUEST;
429
+ }
425
430
  }
426
431
  exports.Module = Module;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/core",
3
- "version": "11.0.11",
3
+ "version": "11.0.12",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@core)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "uid": "2.0.2"
40
40
  },
41
41
  "devDependencies": {
42
- "@nestjs/common": "11.0.11"
42
+ "@nestjs/common": "11.0.12"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@nestjs/common": "^11.0.0",
@@ -5,9 +5,12 @@ export declare class LegacyRouteConverter {
5
5
  * path-to-regexp used by Express>=v5 and @fastify/middie>=v9 no longer support unnamed wildcards.
6
6
  * This method attempts to convert the old syntax to the new one, and logs an error if it fails.
7
7
  * @param route The route to convert.
8
+ * @param options Options object.
8
9
  * @returns The converted route, or the original route if it cannot be converted.
9
10
  */
10
- static tryConvert(route: string): string;
11
+ static tryConvert(route: string, options?: {
12
+ logs?: boolean;
13
+ }): string;
11
14
  static printError(route: string): void;
12
15
  static printWarning(route: string): void;
13
16
  }
@@ -9,35 +9,40 @@ class LegacyRouteConverter {
9
9
  * path-to-regexp used by Express>=v5 and @fastify/middie>=v9 no longer support unnamed wildcards.
10
10
  * This method attempts to convert the old syntax to the new one, and logs an error if it fails.
11
11
  * @param route The route to convert.
12
+ * @param options Options object.
12
13
  * @returns The converted route, or the original route if it cannot be converted.
13
14
  */
14
- static tryConvert(route) {
15
+ static tryConvert(route, options) {
15
16
  // Normalize path to eliminate additional if statements.
16
17
  const routeWithLeadingSlash = route.startsWith('/') ? route : `/${route}`;
17
18
  const normalizedRoute = route.endsWith('/')
18
19
  ? routeWithLeadingSlash
19
20
  : `${routeWithLeadingSlash}/`;
21
+ const loggingEnabled = options?.logs ?? true;
22
+ const printWarning = loggingEnabled
23
+ ? this.printWarning.bind(this)
24
+ : () => { };
20
25
  if (normalizedRoute.endsWith('/(.*)/')) {
21
26
  // Skip printing warning for the "all" wildcard.
22
27
  if (normalizedRoute !== '/(.*)/') {
23
- this.printWarning(route);
28
+ printWarning(route);
24
29
  }
25
30
  return route.replace('(.*)', '{*path}');
26
31
  }
27
32
  if (normalizedRoute.endsWith('/*/')) {
28
33
  // Skip printing warning for the "all" wildcard.
29
34
  if (normalizedRoute !== '/*/') {
30
- this.printWarning(route);
35
+ printWarning(route);
31
36
  }
32
37
  return route.replace('*', '{*path}');
33
38
  }
34
39
  if (normalizedRoute.endsWith('/+/')) {
35
- this.printWarning(route);
40
+ printWarning(route);
36
41
  return route.replace('/+', '/*path');
37
42
  }
38
43
  // When route includes any wildcard segments in the middle.
39
44
  if (normalizedRoute.includes('/*/')) {
40
- this.printWarning(route);
45
+ printWarning(route);
41
46
  // Replace each /*/ segment with a named parameter using different name for each segment.
42
47
  return route.replaceAll('/*/', (match, offset) => {
43
48
  return `/*path${offset}/`;