@nestjs/core 11.1.16 → 11.1.18
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/hooks/utils/get-instances-grouped-by-hierarchy-level.d.ts +3 -0
- package/hooks/utils/get-instances-grouped-by-hierarchy-level.js +27 -0
- package/hooks/utils/get-sorted-hierarchy-levels.d.ts +1 -0
- package/hooks/utils/get-sorted-hierarchy-levels.js +7 -0
- package/index.d.ts +1 -1
- package/injector/injector.js +1 -1
- package/injector/module-ref.js +10 -2
- package/interfaces/index.d.ts +2 -0
- package/interfaces/index.js +2 -0
- package/internal.d.ts +38 -0
- package/internal.js +46 -0
- package/middleware/middleware-module.js +4 -1
- package/nest-factory.d.ts +6 -2
- package/package.json +4 -4
- package/router/sse-stream.js +4 -3
package/Readme.md
CHANGED
|
@@ -29,7 +29,7 @@ Nest is a framework for building efficient, scalable <a href="https://nodejs.org
|
|
|
29
29
|
|
|
30
30
|
## Philosophy
|
|
31
31
|
|
|
32
|
-
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and
|
|
32
|
+
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front-end and back-end applications, giving rise to awesome projects like <a href="https://angular.io/" target="_blank">Angular</a>, <a href="https://github.com/facebook/react" target="_blank">React</a>, and <a href="https://github.com/vuejs/vue" target="_blank">Vue</a>, which improve developer productivity and enable the construction of fast, testable, and extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers, and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
|
33
33
|
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, and loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
|
34
34
|
|
|
35
35
|
## Getting started
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { InjectionToken } from '@nestjs/common';
|
|
2
|
+
import { InstanceWrapper } from '../../injector/instance-wrapper.js';
|
|
3
|
+
export declare function getInstancesGroupedByHierarchyLevel(...collections: Array<Map<InjectionToken, InstanceWrapper> | Array<[InjectionToken, InstanceWrapper]>>): Map<number, unknown[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function getInstancesGroupedByHierarchyLevel(...collections) {
|
|
2
|
+
const groupedByHierarchyLevel = new Map();
|
|
3
|
+
for (const collection of collections) {
|
|
4
|
+
for (const [_, wrapper] of collection) {
|
|
5
|
+
if (!wrapper.isDependencyTreeStatic()) {
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
const level = wrapper.hierarchyLevel;
|
|
9
|
+
if (!groupedByHierarchyLevel.has(level)) {
|
|
10
|
+
groupedByHierarchyLevel.set(level, []);
|
|
11
|
+
}
|
|
12
|
+
const byHierarchyLevelGroup = groupedByHierarchyLevel.get(level);
|
|
13
|
+
if (wrapper.isTransient) {
|
|
14
|
+
const staticTransientInstances = wrapper
|
|
15
|
+
.getStaticTransientInstances()
|
|
16
|
+
.filter(i => !!i)
|
|
17
|
+
.map(i => i.instance);
|
|
18
|
+
byHierarchyLevelGroup.push(...staticTransientInstances);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (wrapper.instance) {
|
|
22
|
+
byHierarchyLevelGroup.push(wrapper.instance);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return groupedByHierarchyLevel;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSortedHierarchyLevels(groups: Map<number, unknown[]>, order?: 'ASC' | 'DESC'): number[];
|
package/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export * from './metadata-scanner';
|
|
|
11
11
|
export * from './middleware';
|
|
12
12
|
export * from './nest-application';
|
|
13
13
|
export * from './nest-application-context';
|
|
14
|
-
export { NestFactory } from './nest-factory';
|
|
14
|
+
export { IEntryNestModule, NestFactory } from './nest-factory';
|
|
15
15
|
export * from './repl';
|
|
16
16
|
export * from './router';
|
|
17
17
|
export * from './services';
|
package/injector/injector.js
CHANGED
|
@@ -210,7 +210,7 @@ class Injector {
|
|
|
210
210
|
];
|
|
211
211
|
const selfParams = this.reflectSelfParams(type);
|
|
212
212
|
selfParams.forEach(({ index, param }) => (paramtypes[index] = param));
|
|
213
|
-
return paramtypes;
|
|
213
|
+
return Array.from(paramtypes);
|
|
214
214
|
}
|
|
215
215
|
reflectOptionalParams(type) {
|
|
216
216
|
return Reflect.getMetadata(constants_1.OPTIONAL_DEPS_METADATA, type) || [];
|
package/injector/module-ref.js
CHANGED
|
@@ -5,6 +5,7 @@ const common_1 = require("@nestjs/common");
|
|
|
5
5
|
const get_class_scope_1 = require("../helpers/get-class-scope");
|
|
6
6
|
const is_durable_1 = require("../helpers/is-durable");
|
|
7
7
|
const abstract_instance_resolver_1 = require("./abstract-instance-resolver");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
8
9
|
const injector_1 = require("./injector");
|
|
9
10
|
const instance_links_host_1 = require("./instance-links-host");
|
|
10
11
|
const instance_wrapper_1 = require("./instance-wrapper");
|
|
@@ -46,16 +47,23 @@ class ModuleRef extends abstract_instance_resolver_1.AbstractInstanceResolver {
|
|
|
46
47
|
durable: (0, is_durable_1.isDurable)(type),
|
|
47
48
|
host: moduleRef,
|
|
48
49
|
});
|
|
50
|
+
if (type?.prototype) {
|
|
51
|
+
wrapper.setInstanceByContextId(contextId ?? constants_1.STATIC_CONTEXT, {
|
|
52
|
+
instance: Object.create(type.prototype),
|
|
53
|
+
isResolved: false,
|
|
54
|
+
isPending: false,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
49
57
|
/* eslint-disable-next-line no-async-promise-executor */
|
|
50
58
|
return new Promise(async (resolve, reject) => {
|
|
51
59
|
try {
|
|
52
60
|
const callback = async (instances) => {
|
|
53
|
-
const properties = await this.injector.resolveProperties(wrapper, moduleRef, undefined, contextId);
|
|
61
|
+
const properties = await this.injector.resolveProperties(wrapper, moduleRef, undefined, contextId, wrapper);
|
|
54
62
|
const instance = new type(...instances);
|
|
55
63
|
this.injector.applyProperties(instance, properties);
|
|
56
64
|
resolve(instance);
|
|
57
65
|
};
|
|
58
|
-
await this.injector.resolveConstructorParams(wrapper, moduleRef, undefined, callback, contextId);
|
|
66
|
+
await this.injector.resolveConstructorParams(wrapper, moduleRef, undefined, callback, contextId, wrapper);
|
|
59
67
|
}
|
|
60
68
|
catch (err) {
|
|
61
69
|
reject(err);
|
package/internal.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal module - not part of the public API.
|
|
3
|
+
* These exports are used by sibling @nestjs packages.
|
|
4
|
+
* Do not depend on these in your application code.
|
|
5
|
+
* @internal
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export { RuntimeException } from './errors/exceptions/runtime.exception.js';
|
|
9
|
+
export { InvalidExceptionFilterException } from './errors/exceptions/invalid-exception-filter.exception.js';
|
|
10
|
+
export { MESSAGES } from './constants.js';
|
|
11
|
+
export { DependenciesScanner } from './scanner.js';
|
|
12
|
+
export { Injector, InjectorDependencyContext } from './injector/injector.js';
|
|
13
|
+
export { InstanceLoader } from './injector/instance-loader.js';
|
|
14
|
+
export { InstanceWrapper } from './injector/instance-wrapper.js';
|
|
15
|
+
export { Module } from './injector/module.js';
|
|
16
|
+
export { STATIC_CONTEXT } from './injector/constants.js';
|
|
17
|
+
export { ExecutionContextHost } from './helpers/execution-context-host.js';
|
|
18
|
+
export { ContextUtils, ParamProperties } from './helpers/context-utils.js';
|
|
19
|
+
export { HandlerMetadataStorage } from './helpers/handler-metadata-storage.js';
|
|
20
|
+
export { RouterMethodFactory } from './helpers/router-method-factory.js';
|
|
21
|
+
export { loadAdapter } from './helpers/load-adapter.js';
|
|
22
|
+
export { optionalRequire } from './helpers/optional-require.js';
|
|
23
|
+
export { ParamsMetadata } from './helpers/interfaces/index.js';
|
|
24
|
+
export { GuardsConsumer } from './guards/guards-consumer.js';
|
|
25
|
+
export { GuardsContextCreator } from './guards/guards-context-creator.js';
|
|
26
|
+
export { FORBIDDEN_MESSAGE } from './guards/constants.js';
|
|
27
|
+
export { PipesConsumer } from './pipes/pipes-consumer.js';
|
|
28
|
+
export { PipesContextCreator } from './pipes/pipes-context-creator.js';
|
|
29
|
+
export { ParamsTokenFactory } from './pipes/params-token-factory.js';
|
|
30
|
+
export { InterceptorsConsumer } from './interceptors/interceptors-consumer.js';
|
|
31
|
+
export { InterceptorsContextCreator } from './interceptors/interceptors-context-creator.js';
|
|
32
|
+
export { BaseExceptionFilterContext } from './exceptions/base-exception-filter-context.js';
|
|
33
|
+
export { LegacyRouteConverter } from './router/legacy-route-converter.js';
|
|
34
|
+
export { REQUEST_CONTEXT_ID } from './router/request/request-constants.js';
|
|
35
|
+
export { NoopGraphInspector } from './inspector/noop-graph-inspector.js';
|
|
36
|
+
export { UuidFactory, UuidFactoryMode } from './inspector/uuid-factory.js';
|
|
37
|
+
export { ModuleDefinition } from './interfaces/module-definition.interface.js';
|
|
38
|
+
export { ModuleOverride } from './interfaces/module-override.interface.js';
|
package/internal.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal module - not part of the public API.
|
|
3
|
+
* These exports are used by sibling @nestjs packages.
|
|
4
|
+
* Do not depend on these in your application code.
|
|
5
|
+
* @internal
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
// Errors
|
|
9
|
+
export { RuntimeException } from './errors/exceptions/runtime.exception.js';
|
|
10
|
+
export { InvalidExceptionFilterException } from './errors/exceptions/invalid-exception-filter.exception.js';
|
|
11
|
+
// Constants
|
|
12
|
+
export { MESSAGES } from './constants.js';
|
|
13
|
+
// Scanner
|
|
14
|
+
export { DependenciesScanner } from './scanner.js';
|
|
15
|
+
// Injector
|
|
16
|
+
export { Injector } from './injector/injector.js';
|
|
17
|
+
export { InstanceLoader } from './injector/instance-loader.js';
|
|
18
|
+
export { InstanceWrapper } from './injector/instance-wrapper.js';
|
|
19
|
+
export { Module } from './injector/module.js';
|
|
20
|
+
export { STATIC_CONTEXT } from './injector/constants.js';
|
|
21
|
+
// Helpers
|
|
22
|
+
export { ExecutionContextHost } from './helpers/execution-context-host.js';
|
|
23
|
+
export { ContextUtils } from './helpers/context-utils.js';
|
|
24
|
+
export { HandlerMetadataStorage } from './helpers/handler-metadata-storage.js';
|
|
25
|
+
export { RouterMethodFactory } from './helpers/router-method-factory.js';
|
|
26
|
+
export { loadAdapter } from './helpers/load-adapter.js';
|
|
27
|
+
export { optionalRequire } from './helpers/optional-require.js';
|
|
28
|
+
// Guards
|
|
29
|
+
export { GuardsConsumer } from './guards/guards-consumer.js';
|
|
30
|
+
export { GuardsContextCreator } from './guards/guards-context-creator.js';
|
|
31
|
+
export { FORBIDDEN_MESSAGE } from './guards/constants.js';
|
|
32
|
+
// Pipes
|
|
33
|
+
export { PipesConsumer } from './pipes/pipes-consumer.js';
|
|
34
|
+
export { PipesContextCreator } from './pipes/pipes-context-creator.js';
|
|
35
|
+
export { ParamsTokenFactory } from './pipes/params-token-factory.js';
|
|
36
|
+
// Interceptors
|
|
37
|
+
export { InterceptorsConsumer } from './interceptors/interceptors-consumer.js';
|
|
38
|
+
export { InterceptorsContextCreator } from './interceptors/interceptors-context-creator.js';
|
|
39
|
+
// Exceptions
|
|
40
|
+
export { BaseExceptionFilterContext } from './exceptions/base-exception-filter-context.js';
|
|
41
|
+
// Router
|
|
42
|
+
export { LegacyRouteConverter } from './router/legacy-route-converter.js';
|
|
43
|
+
export { REQUEST_CONTEXT_ID } from './router/request/request-constants.js';
|
|
44
|
+
// Inspector
|
|
45
|
+
export { NoopGraphInspector } from './inspector/noop-graph-inspector.js';
|
|
46
|
+
export { UuidFactory, UuidFactoryMode } from './inspector/uuid-factory.js';
|
|
@@ -174,7 +174,10 @@ class MiddlewareModule {
|
|
|
174
174
|
const middlewareFunction = isMethodAll
|
|
175
175
|
? proxy
|
|
176
176
|
: (req, res, next) => {
|
|
177
|
-
|
|
177
|
+
const actualRequestMethod = applicationRef.getRequestMethod?.(req);
|
|
178
|
+
if (actualRequestMethod === requestMethod ||
|
|
179
|
+
(actualRequestMethod === request_method_enum_1.RequestMethod[request_method_enum_1.RequestMethod.HEAD] &&
|
|
180
|
+
requestMethod === request_method_enum_1.RequestMethod[request_method_enum_1.RequestMethod.GET])) {
|
|
178
181
|
return proxy(req, res, next);
|
|
179
182
|
}
|
|
180
183
|
return next();
|
package/nest-factory.d.ts
CHANGED
|
@@ -3,7 +3,12 @@ import { NestMicroserviceOptions } from '@nestjs/common/interfaces/microservices
|
|
|
3
3
|
import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
|
|
4
4
|
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
|
5
5
|
import { AbstractHttpAdapter } from './adapters/http-adapter';
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Represents the entry (root) module type accepted by the NestFactory methods.
|
|
8
|
+
*
|
|
9
|
+
* @publicApi
|
|
10
|
+
*/
|
|
11
|
+
export type IEntryNestModule = Type<any> | DynamicModule | ForwardReference | Promise<IEntryNestModule>;
|
|
7
12
|
/**
|
|
8
13
|
* @publicApi
|
|
9
14
|
*/
|
|
@@ -80,4 +85,3 @@ export declare class NestFactoryStatic {
|
|
|
80
85
|
* @publicApi
|
|
81
86
|
*/
|
|
82
87
|
export declare const NestFactory: NestFactoryStatic;
|
|
83
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.18",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"@nuxt/opencollective": "0.4.1",
|
|
35
35
|
"fast-safe-stringify": "2.1.1",
|
|
36
36
|
"iterare": "1.2.1",
|
|
37
|
-
"path-to-regexp": "8.
|
|
37
|
+
"path-to-regexp": "8.4.2",
|
|
38
38
|
"tslib": "2.8.1",
|
|
39
39
|
"uid": "2.0.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@nestjs/common": "11.1.
|
|
42
|
+
"@nestjs/common": "11.1.18"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@nestjs/common": "^11.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"optional": true
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3c1cc5f91e95fcec27c3694cd42a08a50e85cc5f"
|
|
64
64
|
}
|
package/router/sse-stream.js
CHANGED
|
@@ -56,9 +56,10 @@ class SseStream extends stream_1.Transform {
|
|
|
56
56
|
return super.pipe(destination, options);
|
|
57
57
|
}
|
|
58
58
|
_transform(message, encoding, callback) {
|
|
59
|
-
|
|
60
|
-
data
|
|
61
|
-
data += message.
|
|
59
|
+
const sanitize = (val) => String(val).replace(/[\r\n]/g, '');
|
|
60
|
+
let data = message.type ? `event: ${sanitize(message.type)}\n` : '';
|
|
61
|
+
data += message.id ? `id: ${sanitize(message.id)}\n` : '';
|
|
62
|
+
data += message.retry ? `retry: ${sanitize(message.retry)}\n` : '';
|
|
62
63
|
data += message.data ? toDataString(message.data) : '';
|
|
63
64
|
data += '\n';
|
|
64
65
|
this.push(data);
|