@nestjs/core 8.3.1 → 8.4.2
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/discovery/discovery-module.js +1 -1
- package/discovery/discovery-service.js +3 -3
- package/errors/exceptions/invalid-class-module.exception.js +1 -1
- package/errors/exceptions/invalid-class-scope.exception.js +2 -2
- package/errors/exceptions/invalid-class.exception.js +1 -1
- package/errors/exceptions/invalid-middleware.exception.js +1 -1
- package/errors/exceptions/invalid-module.exception.js +1 -1
- package/errors/exceptions/undefined-dependency.exception.js +1 -1
- package/errors/exceptions/undefined-forwardref.exception.js +1 -1
- package/errors/exceptions/undefined-module.exception.js +1 -1
- package/errors/exceptions/unknown-dependencies.exception.js +1 -1
- package/errors/exceptions/unknown-export.exception.js +1 -1
- package/errors/messages.js +9 -9
- package/exceptions/base-exception-filter-context.js +3 -3
- package/exceptions/base-exception-filter.js +4 -4
- package/exceptions/exceptions-handler.js +1 -1
- package/exceptions/external-exception-filter-context.js +2 -2
- package/exceptions/external-exceptions-handler.js +1 -1
- package/guards/guards-consumer.js +2 -2
- package/guards/guards-context-creator.js +4 -4
- package/helpers/context-utils.js +1 -1
- package/helpers/external-context-creator.js +3 -3
- package/hooks/before-app-shutdown.hook.js +5 -5
- package/hooks/on-app-bootstrap.hook.js +5 -5
- package/hooks/on-app-shutdown.hook.js +5 -5
- package/hooks/on-module-destroy.hook.js +5 -5
- package/hooks/on-module-init.hook.js +5 -5
- package/injector/helpers/transient-instances.js +2 -2
- package/injector/injector.d.ts +4 -1
- package/injector/injector.js +48 -19
- package/injector/instance-links-host.js +1 -2
- package/injector/instance-loader.js +1 -1
- package/injector/instance-wrapper.d.ts +2 -1
- package/injector/instance-wrapper.js +6 -6
- package/injector/internal-core-module.js +2 -2
- package/injector/module-ref.js +1 -1
- package/injector/module-token-factory.js +4 -4
- package/injector/module.d.ts +12 -8
- package/injector/module.js +21 -24
- package/injector/modules-container.js +1 -1
- package/interceptors/interceptors-consumer.js +4 -4
- package/interceptors/interceptors-context-creator.js +4 -4
- package/metadata-scanner.js +4 -4
- package/middleware/builder.js +3 -3
- package/middleware/container.js +1 -1
- package/middleware/middleware-module.js +9 -8
- package/middleware/routes-mapper.js +6 -6
- package/middleware/utils.js +6 -6
- package/nest-application-context.js +9 -10
- package/nest-application.js +13 -13
- package/nest-factory.js +6 -6
- package/package.json +3 -3
- package/pipes/pipes-context-creator.js +4 -4
- package/router/route-path-factory.js +8 -8
- package/router/router-exception-filters.js +2 -2
- package/router/router-execution-context.js +4 -4
- package/router/router-explorer.js +36 -12
- package/router/router-module.js +4 -4
- package/router/router-response-controller.js +6 -6
- package/router/routes-resolver.js +2 -2
- package/router/sse-stream.js +1 -1
- package/router/utils/exclude-route.util.js +1 -1
- package/router/utils/flatten-route-paths.util.js +2 -2
- package/scanner.js +10 -10
- package/services/reflector.service.js +2 -2
- package/CHANGELOG.md +0 -12
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MiddlewareModule = void 0;
|
|
4
4
|
const request_method_enum_1 = require("@nestjs/common/enums/request-method.enum");
|
|
5
5
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
6
|
-
const utils_1 = require("../router/utils");
|
|
7
6
|
const invalid_middleware_exception_1 = require("../errors/exceptions/invalid-middleware.exception");
|
|
8
7
|
const runtime_exception_1 = require("../errors/exceptions/runtime.exception");
|
|
9
8
|
const context_id_factory_1 = require("../helpers/context-id-factory");
|
|
@@ -12,6 +11,7 @@ const constants_1 = require("../injector/constants");
|
|
|
12
11
|
const request_constants_1 = require("../router/request/request-constants");
|
|
13
12
|
const router_exception_filters_1 = require("../router/router-exception-filters");
|
|
14
13
|
const router_proxy_1 = require("../router/router-proxy");
|
|
14
|
+
const utils_1 = require("../router/utils");
|
|
15
15
|
const builder_1 = require("./builder");
|
|
16
16
|
const resolver_1 = require("./resolver");
|
|
17
17
|
const routes_mapper_1 = require("./routes-mapper");
|
|
@@ -80,7 +80,7 @@ class MiddlewareModule {
|
|
|
80
80
|
for (const metatype of middlewareCollection) {
|
|
81
81
|
const collection = middlewareContainer.getMiddlewareCollection(moduleKey);
|
|
82
82
|
const instanceWrapper = collection.get(metatype);
|
|
83
|
-
if (shared_utils_1.isUndefined(instanceWrapper)) {
|
|
83
|
+
if ((0, shared_utils_1.isUndefined)(instanceWrapper)) {
|
|
84
84
|
throw new runtime_exception_1.RuntimeException();
|
|
85
85
|
}
|
|
86
86
|
if (instanceWrapper.isTransient) {
|
|
@@ -91,7 +91,7 @@ class MiddlewareModule {
|
|
|
91
91
|
}
|
|
92
92
|
async bindHandler(wrapper, applicationRef, method, path, moduleRef, collection) {
|
|
93
93
|
const { instance, metatype } = wrapper;
|
|
94
|
-
if (shared_utils_1.isUndefined(instance === null || instance === void 0 ? void 0 : instance.use)) {
|
|
94
|
+
if ((0, shared_utils_1.isUndefined)(instance === null || instance === void 0 ? void 0 : instance.use)) {
|
|
95
95
|
throw new invalid_middleware_exception_1.InvalidMiddlewareException(metatype.name);
|
|
96
96
|
}
|
|
97
97
|
const isStatic = wrapper.isDependencyTreeStatic();
|
|
@@ -134,12 +134,13 @@ class MiddlewareModule {
|
|
|
134
134
|
async registerHandler(applicationRef, method, path, proxy) {
|
|
135
135
|
const prefix = this.config.getGlobalPrefix();
|
|
136
136
|
const excludedRoutes = this.config.getGlobalPrefixOptions().exclude;
|
|
137
|
-
if (Array.isArray(excludedRoutes) &&
|
|
138
|
-
utils_1.isRouteExcluded(excludedRoutes, path, method))
|
|
139
|
-
|
|
137
|
+
if ((Array.isArray(excludedRoutes) &&
|
|
138
|
+
(0, utils_1.isRouteExcluded)(excludedRoutes, path, method)) ||
|
|
139
|
+
['*', '/*', '(.*)', '/(.*)'].includes(path)) {
|
|
140
|
+
path = (0, shared_utils_1.addLeadingSlash)(path);
|
|
140
141
|
}
|
|
141
142
|
else {
|
|
142
|
-
const basePath = shared_utils_1.addLeadingSlash(prefix);
|
|
143
|
+
const basePath = (0, shared_utils_1.addLeadingSlash)(prefix);
|
|
143
144
|
if ((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) && (path === null || path === void 0 ? void 0 : path.startsWith('/'))) {
|
|
144
145
|
// strip slash when a wildcard is being used
|
|
145
146
|
// and global prefix has been set
|
|
@@ -147,7 +148,7 @@ class MiddlewareModule {
|
|
|
147
148
|
}
|
|
148
149
|
path = basePath + path;
|
|
149
150
|
}
|
|
150
|
-
const isMethodAll = utils_1.isRequestMethodAll(method);
|
|
151
|
+
const isMethodAll = (0, utils_1.isRequestMethodAll)(method);
|
|
151
152
|
const requestMethod = request_method_enum_1.RequestMethod[method];
|
|
152
153
|
const router = await applicationRef.createMiddlewareFactory(method);
|
|
153
154
|
router(path, isMethodAll
|
|
@@ -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) {
|
package/middleware/utils.js
CHANGED
|
@@ -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))
|
|
@@ -138,7 +138,6 @@ class NestApplicationContext {
|
|
|
138
138
|
*/
|
|
139
139
|
listenToShutdownSignals(signals) {
|
|
140
140
|
const cleanup = async (signal) => {
|
|
141
|
-
var _a;
|
|
142
141
|
try {
|
|
143
142
|
signals.forEach(sig => process.removeListener(sig, cleanup));
|
|
144
143
|
await this.callDestroyHook();
|
|
@@ -148,7 +147,7 @@ class NestApplicationContext {
|
|
|
148
147
|
process.kill(process.pid, signal);
|
|
149
148
|
}
|
|
150
149
|
catch (err) {
|
|
151
|
-
common_1.Logger.error(constants_1.MESSAGES.ERROR_DURING_SHUTDOWN,
|
|
150
|
+
common_1.Logger.error(constants_1.MESSAGES.ERROR_DURING_SHUTDOWN, err === null || err === void 0 ? void 0 : err.stack, NestApplicationContext.name);
|
|
152
151
|
process.exit(1);
|
|
153
152
|
}
|
|
154
153
|
};
|
|
@@ -176,7 +175,7 @@ class NestApplicationContext {
|
|
|
176
175
|
async callInitHook() {
|
|
177
176
|
const modulesSortedByDistance = this.getModulesSortedByDistance();
|
|
178
177
|
for (const module of modulesSortedByDistance) {
|
|
179
|
-
await hooks_1.callModuleInitHook(module);
|
|
178
|
+
await (0, hooks_1.callModuleInitHook)(module);
|
|
180
179
|
}
|
|
181
180
|
}
|
|
182
181
|
/**
|
|
@@ -186,7 +185,7 @@ class NestApplicationContext {
|
|
|
186
185
|
async callDestroyHook() {
|
|
187
186
|
const modulesSortedByDistance = this.getModulesSortedByDistance();
|
|
188
187
|
for (const module of modulesSortedByDistance) {
|
|
189
|
-
await hooks_1.callModuleDestroyHook(module);
|
|
188
|
+
await (0, hooks_1.callModuleDestroyHook)(module);
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
/**
|
|
@@ -196,7 +195,7 @@ class NestApplicationContext {
|
|
|
196
195
|
async callBootstrapHook() {
|
|
197
196
|
const modulesSortedByDistance = this.getModulesSortedByDistance();
|
|
198
197
|
for (const module of modulesSortedByDistance) {
|
|
199
|
-
await hooks_1.callModuleBootstrapHook(module);
|
|
198
|
+
await (0, hooks_1.callModuleBootstrapHook)(module);
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
/**
|
|
@@ -206,7 +205,7 @@ class NestApplicationContext {
|
|
|
206
205
|
async callShutdownHook(signal) {
|
|
207
206
|
const modulesSortedByDistance = this.getModulesSortedByDistance();
|
|
208
207
|
for (const module of modulesSortedByDistance) {
|
|
209
|
-
await hooks_1.callAppShutdownHook(module, signal);
|
|
208
|
+
await (0, hooks_1.callAppShutdownHook)(module, signal);
|
|
210
209
|
}
|
|
211
210
|
}
|
|
212
211
|
/**
|
|
@@ -216,7 +215,7 @@ class NestApplicationContext {
|
|
|
216
215
|
async callBeforeShutdownHook(signal) {
|
|
217
216
|
const modulesSortedByDistance = this.getModulesSortedByDistance();
|
|
218
217
|
for (const module of modulesSortedByDistance) {
|
|
219
|
-
await hooks_1.callBeforeAppShutdownHook(module, signal);
|
|
218
|
+
await (0, hooks_1.callBeforeAppShutdownHook)(module, signal);
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
221
|
find(typeOrToken, contextModule) {
|
package/nest-application.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"@nuxtjs/opencollective": "0.3.2",
|
|
31
31
|
"fast-safe-stringify": "2.1.1",
|
|
32
32
|
"iterare": "1.2.1",
|
|
33
|
-
"object-hash": "
|
|
33
|
+
"object-hash": "3.0.0",
|
|
34
34
|
"path-to-regexp": "3.2.0",
|
|
35
35
|
"tslib": "2.3.1",
|
|
36
36
|
"uuid": "8.3.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nestjs/common": "8.
|
|
39
|
+
"@nestjs/common": "8.4.2"
|
|
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)
|
|
@@ -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
|
});
|
|
@@ -178,6 +178,30 @@ class RouterExplorer {
|
|
|
178
178
|
if (versioningOptions.type === version_type_enum_1.VersioningType.URI) {
|
|
179
179
|
return handler(req, res, next);
|
|
180
180
|
}
|
|
181
|
+
// Custom Extractor Versioning Handler
|
|
182
|
+
if (versioningOptions.type === version_type_enum_1.VersioningType.CUSTOM) {
|
|
183
|
+
const extractedVersion = versioningOptions.extractor(req);
|
|
184
|
+
if (Array.isArray(version)) {
|
|
185
|
+
if (Array.isArray(extractedVersion) &&
|
|
186
|
+
version.filter(extractedVersion.includes).length) {
|
|
187
|
+
return handler(req, res, next);
|
|
188
|
+
}
|
|
189
|
+
else if ((0, shared_utils_1.isString)(extractedVersion) &&
|
|
190
|
+
version.includes(extractedVersion)) {
|
|
191
|
+
return handler(req, res, next);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
if (Array.isArray(extractedVersion) &&
|
|
196
|
+
extractedVersion.includes(version)) {
|
|
197
|
+
return handler(req, res, next);
|
|
198
|
+
}
|
|
199
|
+
else if ((0, shared_utils_1.isString)(extractedVersion) &&
|
|
200
|
+
version === extractedVersion) {
|
|
201
|
+
return handler(req, res, next);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
181
205
|
// Media Type (Accept Header) Versioning Handler
|
|
182
206
|
if (versioningOptions.type === version_type_enum_1.VersioningType.MEDIA_TYPE) {
|
|
183
207
|
const MEDIA_TYPE_HEADER = 'Accept';
|
|
@@ -193,7 +217,7 @@ class RouterExplorer {
|
|
|
193
217
|
return handler(req, res, next);
|
|
194
218
|
}
|
|
195
219
|
}
|
|
196
|
-
else if (shared_utils_1.isString(version)) {
|
|
220
|
+
else if ((0, shared_utils_1.isString)(version)) {
|
|
197
221
|
if (version === headerVersion) {
|
|
198
222
|
return handler(req, res, next);
|
|
199
223
|
}
|
|
@@ -210,7 +234,7 @@ class RouterExplorer {
|
|
|
210
234
|
return handler(req, res, next);
|
|
211
235
|
}
|
|
212
236
|
}
|
|
213
|
-
else if (shared_utils_1.isString(version)) {
|
|
237
|
+
else if ((0, shared_utils_1.isString)(version)) {
|
|
214
238
|
if (version === customHeaderVersionParameter) {
|
|
215
239
|
return handler(req, res, next);
|
|
216
240
|
}
|