@nestjs/core 8.4.0 → 8.4.1
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/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.js +16 -15
- package/injector/instance-links-host.js +1 -2
- package/injector/instance-loader.js +1 -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.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 +2 -2
- 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 +14 -14
- 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 +9 -9
- package/services/reflector.service.js +2 -2
|
@@ -47,8 +47,7 @@ class InstanceLinksHost {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
getInstanceNameByToken(token) {
|
|
50
|
-
|
|
51
|
-
return shared_utils_1.isFunction(token) ? (_a = token) === null || _a === void 0 ? void 0 : _a.name : token;
|
|
50
|
+
return (0, shared_utils_1.isFunction)(token) ? token === null || token === void 0 ? void 0 : token.name : token;
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
exports.InstanceLinksHost = InstanceLinksHost;
|
|
@@ -31,7 +31,7 @@ class InstanceLoader {
|
|
|
31
31
|
await this.createInstancesOfControllers(moduleRef);
|
|
32
32
|
const { name } = moduleRef.metatype;
|
|
33
33
|
this.isModuleWhitelisted(name) &&
|
|
34
|
-
this.logger.log(messages_1.MODULE_INIT_MESSAGE `${name}`);
|
|
34
|
+
this.logger.log((0, messages_1.MODULE_INIT_MESSAGE) `${name}`);
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
37
|
createPrototypesOfProviders(moduleRef) {
|
|
@@ -16,7 +16,7 @@ class InstanceWrapper {
|
|
|
16
16
|
this.scope = common_1.Scope.DEFAULT;
|
|
17
17
|
this.values = new WeakMap();
|
|
18
18
|
this[_a] = {};
|
|
19
|
-
this[exports.INSTANCE_ID_SYMBOL] = random_string_generator_util_1.randomStringGenerator();
|
|
19
|
+
this[exports.INSTANCE_ID_SYMBOL] = (0, random_string_generator_util_1.randomStringGenerator)();
|
|
20
20
|
this.initialize(metadata);
|
|
21
21
|
}
|
|
22
22
|
get id() {
|
|
@@ -30,7 +30,7 @@ class InstanceWrapper {
|
|
|
30
30
|
return instancePerContext.instance;
|
|
31
31
|
}
|
|
32
32
|
get isNotMetatype() {
|
|
33
|
-
const isFactory = this.metatype && !shared_utils_1.isNil(this.inject);
|
|
33
|
+
const isFactory = this.metatype && !(0, shared_utils_1.isNil)(this.inject);
|
|
34
34
|
return !this.metatype || isFactory;
|
|
35
35
|
}
|
|
36
36
|
get isTransient() {
|
|
@@ -101,7 +101,7 @@ class InstanceWrapper {
|
|
|
101
101
|
return this[exports.INSTANCE_METADATA_SYMBOL].enhancers;
|
|
102
102
|
}
|
|
103
103
|
isDependencyTreeStatic(lookupRegistry = []) {
|
|
104
|
-
if (!shared_utils_1.isUndefined(this.isTreeStatic)) {
|
|
104
|
+
if (!(0, shared_utils_1.isUndefined)(this.isTreeStatic)) {
|
|
105
105
|
return this.isTreeStatic;
|
|
106
106
|
}
|
|
107
107
|
if (this.scope === common_1.Scope.REQUEST) {
|
|
@@ -190,13 +190,13 @@ class InstanceWrapper {
|
|
|
190
190
|
return [];
|
|
191
191
|
}
|
|
192
192
|
const instances = [...this.transientMap.values()];
|
|
193
|
-
return iterare_1.iterate(instances)
|
|
193
|
+
return (0, iterare_1.iterate)(instances)
|
|
194
194
|
.map(item => item.get(constants_1.STATIC_CONTEXT))
|
|
195
195
|
.filter(item => !!item)
|
|
196
196
|
.toArray();
|
|
197
197
|
}
|
|
198
198
|
mergeWith(provider) {
|
|
199
|
-
if (!shared_utils_1.isUndefined(provider.useValue)) {
|
|
199
|
+
if (!(0, shared_utils_1.isUndefined)(provider.useValue)) {
|
|
200
200
|
this.metatype = null;
|
|
201
201
|
this.inject = null;
|
|
202
202
|
this.scope = common_1.Scope.DEFAULT;
|
|
@@ -216,7 +216,7 @@ class InstanceWrapper {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
isNewable() {
|
|
219
|
-
return shared_utils_1.isNil(this.inject) && this.metatype && this.metatype.prototype;
|
|
219
|
+
return (0, shared_utils_1.isNil)(this.inject) && this.metatype && this.metatype.prototype;
|
|
220
220
|
}
|
|
221
221
|
isWrapperListStatic(tree, lookupRegistry) {
|
|
222
222
|
return tree.every((item) => item.isDependencyTreeStatic(lookupRegistry));
|
|
@@ -21,8 +21,8 @@ let InternalCoreModule = InternalCoreModule_1 = class InternalCoreModule {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
InternalCoreModule = InternalCoreModule_1 = tslib_1.__decorate([
|
|
24
|
-
common_1.Global(),
|
|
25
|
-
common_1.Module({
|
|
24
|
+
(0, common_1.Global)(),
|
|
25
|
+
(0, common_1.Module)({
|
|
26
26
|
providers: [
|
|
27
27
|
services_1.Reflector,
|
|
28
28
|
ReflectorAliasProvider,
|
package/injector/module-ref.js
CHANGED
|
@@ -63,7 +63,7 @@ class ModuleRef {
|
|
|
63
63
|
name: type && type.name,
|
|
64
64
|
metatype: type,
|
|
65
65
|
isResolved: false,
|
|
66
|
-
scope: get_class_scope_1.getClassScope(type),
|
|
66
|
+
scope: (0, get_class_scope_1.getClassScope)(type),
|
|
67
67
|
host: moduleRef,
|
|
68
68
|
});
|
|
69
69
|
return new Promise(async (resolve, reject) => {
|
|
@@ -23,7 +23,7 @@ class ModuleTokenFactory {
|
|
|
23
23
|
// The replacer function is also required in order to obtain real class names
|
|
24
24
|
// instead of the unified "Function" key
|
|
25
25
|
return dynamicModuleMetadata
|
|
26
|
-
? fast_safe_stringify_1.default(dynamicModuleMetadata, this.replacer)
|
|
26
|
+
? (0, fast_safe_stringify_1.default)(dynamicModuleMetadata, this.replacer)
|
|
27
27
|
: '';
|
|
28
28
|
}
|
|
29
29
|
getModuleId(metatype) {
|
|
@@ -31,7 +31,7 @@ class ModuleTokenFactory {
|
|
|
31
31
|
if (moduleId) {
|
|
32
32
|
return moduleId;
|
|
33
33
|
}
|
|
34
|
-
moduleId = random_string_generator_util_1.randomStringGenerator();
|
|
34
|
+
moduleId = (0, random_string_generator_util_1.randomStringGenerator)();
|
|
35
35
|
this.moduleIdsCache.set(metatype, moduleId);
|
|
36
36
|
return moduleId;
|
|
37
37
|
}
|
|
@@ -39,7 +39,7 @@ class ModuleTokenFactory {
|
|
|
39
39
|
return metatype.name;
|
|
40
40
|
}
|
|
41
41
|
replacer(key, value) {
|
|
42
|
-
if (shared_utils_1.isFunction(value)) {
|
|
42
|
+
if ((0, shared_utils_1.isFunction)(value)) {
|
|
43
43
|
const funcAsString = value.toString();
|
|
44
44
|
const isClass = /^class\s/.test(funcAsString);
|
|
45
45
|
if (isClass) {
|
|
@@ -47,7 +47,7 @@ class ModuleTokenFactory {
|
|
|
47
47
|
}
|
|
48
48
|
return hash(funcAsString, { ignoreUnknown: true });
|
|
49
49
|
}
|
|
50
|
-
if (shared_utils_1.isSymbol(value)) {
|
|
50
|
+
if ((0, shared_utils_1.isSymbol)(value)) {
|
|
51
51
|
return value.toString();
|
|
52
52
|
}
|
|
53
53
|
return value;
|
package/injector/module.js
CHANGED
|
@@ -25,7 +25,7 @@ class Module {
|
|
|
25
25
|
this._exports = new Set();
|
|
26
26
|
this._distance = 0;
|
|
27
27
|
this.addCoreProviders();
|
|
28
|
-
this._id = random_string_generator_util_1.randomStringGenerator();
|
|
28
|
+
this._id = (0, random_string_generator_util_1.randomStringGenerator)();
|
|
29
29
|
}
|
|
30
30
|
get id() {
|
|
31
31
|
return this._id;
|
|
@@ -135,7 +135,7 @@ class Module {
|
|
|
135
135
|
metatype: injectable,
|
|
136
136
|
instance: null,
|
|
137
137
|
isResolved: false,
|
|
138
|
-
scope: get_class_scope_1.getClassScope(injectable),
|
|
138
|
+
scope: (0, get_class_scope_1.getClassScope)(injectable),
|
|
139
139
|
host: this,
|
|
140
140
|
});
|
|
141
141
|
this._injectables.set(injectable, instanceWrapper);
|
|
@@ -155,13 +155,13 @@ class Module {
|
|
|
155
155
|
metatype: provider,
|
|
156
156
|
instance: null,
|
|
157
157
|
isResolved: false,
|
|
158
|
-
scope: get_class_scope_1.getClassScope(provider),
|
|
158
|
+
scope: (0, get_class_scope_1.getClassScope)(provider),
|
|
159
159
|
host: this,
|
|
160
160
|
}));
|
|
161
161
|
return provider;
|
|
162
162
|
}
|
|
163
163
|
isCustomProvider(provider) {
|
|
164
|
-
return !shared_utils_1.isNil(provider.provide);
|
|
164
|
+
return !(0, shared_utils_1.isNil)(provider.provide);
|
|
165
165
|
}
|
|
166
166
|
addCustomProvider(provider, collection) {
|
|
167
167
|
if (this.isCustomClass(provider)) {
|
|
@@ -179,16 +179,16 @@ class Module {
|
|
|
179
179
|
return provider.provide;
|
|
180
180
|
}
|
|
181
181
|
isCustomClass(provider) {
|
|
182
|
-
return !shared_utils_1.isUndefined(provider.useClass);
|
|
182
|
+
return !(0, shared_utils_1.isUndefined)(provider.useClass);
|
|
183
183
|
}
|
|
184
184
|
isCustomValue(provider) {
|
|
185
|
-
return !shared_utils_1.isUndefined(provider.useValue);
|
|
185
|
+
return !(0, shared_utils_1.isUndefined)(provider.useValue);
|
|
186
186
|
}
|
|
187
187
|
isCustomFactory(provider) {
|
|
188
|
-
return !shared_utils_1.isUndefined(provider.useFactory);
|
|
188
|
+
return !(0, shared_utils_1.isUndefined)(provider.useFactory);
|
|
189
189
|
}
|
|
190
190
|
isCustomUseExisting(provider) {
|
|
191
|
-
return !shared_utils_1.isUndefined(provider.useExisting);
|
|
191
|
+
return !(0, shared_utils_1.isUndefined)(provider.useExisting);
|
|
192
192
|
}
|
|
193
193
|
isDynamicModule(exported) {
|
|
194
194
|
return exported && exported.module;
|
|
@@ -196,8 +196,8 @@ class Module {
|
|
|
196
196
|
addCustomClass(provider, collection) {
|
|
197
197
|
let { scope } = provider;
|
|
198
198
|
const { useClass } = provider;
|
|
199
|
-
if (shared_utils_1.isUndefined(scope)) {
|
|
200
|
-
scope = get_class_scope_1.getClassScope(useClass);
|
|
199
|
+
if ((0, shared_utils_1.isUndefined)(scope)) {
|
|
200
|
+
scope = (0, get_class_scope_1.getClassScope)(useClass);
|
|
201
201
|
}
|
|
202
202
|
collection.set(provider.provide, new instance_wrapper_1.InstanceWrapper({
|
|
203
203
|
token: provider.provide,
|
|
@@ -210,11 +210,10 @@ class Module {
|
|
|
210
210
|
}));
|
|
211
211
|
}
|
|
212
212
|
addCustomValue(provider, collection) {
|
|
213
|
-
var _a;
|
|
214
213
|
const { useValue: value, provide: providerToken } = provider;
|
|
215
214
|
collection.set(providerToken, new instance_wrapper_1.InstanceWrapper({
|
|
216
215
|
token: providerToken,
|
|
217
|
-
name: (
|
|
216
|
+
name: (providerToken === null || providerToken === void 0 ? void 0 : providerToken.name) || providerToken,
|
|
218
217
|
metatype: null,
|
|
219
218
|
instance: value,
|
|
220
219
|
isResolved: true,
|
|
@@ -223,11 +222,10 @@ class Module {
|
|
|
223
222
|
}));
|
|
224
223
|
}
|
|
225
224
|
addCustomFactory(provider, collection) {
|
|
226
|
-
var _a;
|
|
227
225
|
const { useFactory: factory, inject, scope, provide: providerToken, } = provider;
|
|
228
226
|
collection.set(providerToken, new instance_wrapper_1.InstanceWrapper({
|
|
229
227
|
token: providerToken,
|
|
230
|
-
name: (
|
|
228
|
+
name: (providerToken === null || providerToken === void 0 ? void 0 : providerToken.name) || providerToken,
|
|
231
229
|
metatype: factory,
|
|
232
230
|
instance: null,
|
|
233
231
|
isResolved: false,
|
|
@@ -237,11 +235,10 @@ class Module {
|
|
|
237
235
|
}));
|
|
238
236
|
}
|
|
239
237
|
addCustomUseExisting(provider, collection) {
|
|
240
|
-
var _a;
|
|
241
238
|
const { useExisting, provide: providerToken } = provider;
|
|
242
239
|
collection.set(providerToken, new instance_wrapper_1.InstanceWrapper({
|
|
243
240
|
token: providerToken,
|
|
244
|
-
name: (
|
|
241
|
+
name: (providerToken === null || providerToken === void 0 ? void 0 : providerToken.name) || providerToken,
|
|
245
242
|
metatype: (instance => instance),
|
|
246
243
|
instance: null,
|
|
247
244
|
isResolved: false,
|
|
@@ -255,7 +252,7 @@ class Module {
|
|
|
255
252
|
if (this.isCustomProvider(provider)) {
|
|
256
253
|
return this.addCustomExportedProvider(provider);
|
|
257
254
|
}
|
|
258
|
-
else if (shared_utils_1.isString(provider) || shared_utils_1.isSymbol(provider)) {
|
|
255
|
+
else if ((0, shared_utils_1.isString)(provider) || (0, shared_utils_1.isSymbol)(provider)) {
|
|
259
256
|
return addExportedUnit(provider);
|
|
260
257
|
}
|
|
261
258
|
else if (this.isDynamicModule(provider)) {
|
|
@@ -266,7 +263,7 @@ class Module {
|
|
|
266
263
|
}
|
|
267
264
|
addCustomExportedProvider(provider) {
|
|
268
265
|
const provide = provider.provide;
|
|
269
|
-
if (shared_utils_1.isString(provide) || shared_utils_1.isSymbol(provide)) {
|
|
266
|
+
if ((0, shared_utils_1.isString)(provide) || (0, shared_utils_1.isSymbol)(provide)) {
|
|
270
267
|
return this._exports.add(this.validateExportedProvider(provide));
|
|
271
268
|
}
|
|
272
269
|
this._exports.add(this.validateExportedProvider(provide));
|
|
@@ -275,14 +272,14 @@ class Module {
|
|
|
275
272
|
if (this._providers.has(token)) {
|
|
276
273
|
return token;
|
|
277
274
|
}
|
|
278
|
-
const imports = iterare_1.iterate(this._imports.values())
|
|
275
|
+
const imports = (0, iterare_1.iterate)(this._imports.values())
|
|
279
276
|
.filter(item => !!item)
|
|
280
277
|
.map(({ metatype }) => metatype)
|
|
281
278
|
.filter(metatype => !!metatype)
|
|
282
279
|
.toArray();
|
|
283
280
|
if (!imports.includes(token)) {
|
|
284
281
|
const { name } = this.metatype;
|
|
285
|
-
const providerName = shared_utils_1.isFunction(token) ? token.name : token;
|
|
282
|
+
const providerName = (0, shared_utils_1.isFunction)(token) ? token.name : token;
|
|
286
283
|
throw new unknown_export_exception_1.UnknownExportException(providerName, name);
|
|
287
284
|
}
|
|
288
285
|
return token;
|
|
@@ -294,7 +291,7 @@ class Module {
|
|
|
294
291
|
metatype: controller,
|
|
295
292
|
instance: null,
|
|
296
293
|
isResolved: false,
|
|
297
|
-
scope: get_class_scope_1.getClassScope(controller),
|
|
294
|
+
scope: (0, get_class_scope_1.getClassScope)(controller),
|
|
298
295
|
host: this,
|
|
299
296
|
}));
|
|
300
297
|
this.assignControllerUniqueId(controller);
|
|
@@ -304,7 +301,7 @@ class Module {
|
|
|
304
301
|
enumerable: false,
|
|
305
302
|
writable: false,
|
|
306
303
|
configurable: true,
|
|
307
|
-
value: random_string_generator_util_1.randomStringGenerator(),
|
|
304
|
+
value: (0, random_string_generator_util_1.randomStringGenerator)(),
|
|
308
305
|
});
|
|
309
306
|
}
|
|
310
307
|
addRelatedModule(module) {
|
|
@@ -344,11 +341,11 @@ class Module {
|
|
|
344
341
|
? this.find(typeOrToken)
|
|
345
342
|
: this.find(typeOrToken, self);
|
|
346
343
|
}
|
|
347
|
-
resolve(typeOrToken, contextId = context_id_factory_1.createContextId(), options = { strict: true }) {
|
|
344
|
+
resolve(typeOrToken, contextId = (0, context_id_factory_1.createContextId)(), options = { strict: true }) {
|
|
348
345
|
return this.resolvePerContext(typeOrToken, self, contextId, options);
|
|
349
346
|
}
|
|
350
347
|
async create(type) {
|
|
351
|
-
if (!(type && shared_utils_1.isFunction(type) && type.prototype)) {
|
|
348
|
+
if (!(type && (0, shared_utils_1.isFunction)(type) && type.prototype)) {
|
|
352
349
|
throw new invalid_class_exception_1.InvalidClassException(type);
|
|
353
350
|
}
|
|
354
351
|
return this.instantiateClass(type, self);
|
|
@@ -7,18 +7,18 @@ const operators_1 = require("rxjs/operators");
|
|
|
7
7
|
const execution_context_host_1 = require("../helpers/execution-context-host");
|
|
8
8
|
class InterceptorsConsumer {
|
|
9
9
|
async intercept(interceptors, args, instance, callback, next, type) {
|
|
10
|
-
if (shared_utils_1.isEmpty(interceptors)) {
|
|
10
|
+
if ((0, shared_utils_1.isEmpty)(interceptors)) {
|
|
11
11
|
return next();
|
|
12
12
|
}
|
|
13
13
|
const context = this.createContext(args, instance, callback);
|
|
14
14
|
context.setType(type);
|
|
15
|
-
const start$ = rxjs_1.defer(() => this.transformDeferred(next));
|
|
15
|
+
const start$ = (0, rxjs_1.defer)(() => this.transformDeferred(next));
|
|
16
16
|
const nextFn = (i = 0) => async () => {
|
|
17
17
|
if (i >= interceptors.length) {
|
|
18
18
|
return start$;
|
|
19
19
|
}
|
|
20
20
|
const handler = {
|
|
21
|
-
handle: () => rxjs_1.from(nextFn(i + 1)()).pipe(operators_1.mergeAll()),
|
|
21
|
+
handle: () => (0, rxjs_1.from)(nextFn(i + 1)()).pipe((0, operators_1.mergeAll)()),
|
|
22
22
|
};
|
|
23
23
|
return interceptors[i].intercept(context, handler);
|
|
24
24
|
};
|
|
@@ -28,7 +28,7 @@ class InterceptorsConsumer {
|
|
|
28
28
|
return new execution_context_host_1.ExecutionContextHost(args, instance.constructor, callback);
|
|
29
29
|
}
|
|
30
30
|
transformDeferred(next) {
|
|
31
|
-
return rxjs_1.from(next()).pipe(operators_1.switchMap(res => {
|
|
31
|
+
return (0, rxjs_1.from)(next()).pipe((0, operators_1.switchMap)(res => {
|
|
32
32
|
const isDeferred = res instanceof Promise || res instanceof rxjs_1.Observable;
|
|
33
33
|
return isDeferred ? res : Promise.resolve(res);
|
|
34
34
|
}));
|
|
@@ -17,13 +17,13 @@ class InterceptorsContextCreator extends context_creator_1.ContextCreator {
|
|
|
17
17
|
return this.createContext(instance, callback, constants_1.INTERCEPTORS_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(interceptor => interceptor && (interceptor.name || interceptor.intercept))
|
|
25
25
|
.map(interceptor => this.getInterceptorInstance(interceptor, contextId, inquirerId))
|
|
26
|
-
.filter((interceptor) => interceptor && shared_utils_1.isFunction(interceptor.intercept))
|
|
26
|
+
.filter((interceptor) => interceptor && (0, shared_utils_1.isFunction)(interceptor.intercept))
|
|
27
27
|
.toArray();
|
|
28
28
|
}
|
|
29
29
|
getInterceptorInstance(metatype, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
|
|
@@ -58,7 +58,7 @@ class InterceptorsContextCreator extends context_creator_1.ContextCreator {
|
|
|
58
58
|
return globalInterceptors;
|
|
59
59
|
}
|
|
60
60
|
const scopedInterceptorWrappers = this.config.getGlobalRequestInterceptors();
|
|
61
|
-
const scopedInterceptors = iterare_1.iterate(scopedInterceptorWrappers)
|
|
61
|
+
const scopedInterceptors = (0, iterare_1.iterate)(scopedInterceptorWrappers)
|
|
62
62
|
.map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
|
|
63
63
|
.filter(host => !!host)
|
|
64
64
|
.map(host => host.instance)
|
package/metadata-scanner.js
CHANGED
|
@@ -6,9 +6,9 @@ const iterare_1 = require("iterare");
|
|
|
6
6
|
class MetadataScanner {
|
|
7
7
|
scanFromPrototype(instance, prototype, callback) {
|
|
8
8
|
const methodNames = new Set(this.getAllFilteredMethodNames(prototype));
|
|
9
|
-
return iterare_1.iterate(methodNames)
|
|
9
|
+
return (0, iterare_1.iterate)(methodNames)
|
|
10
10
|
.map(callback)
|
|
11
|
-
.filter(metadata => !shared_utils_1.isNil(metadata))
|
|
11
|
+
.filter(metadata => !(0, shared_utils_1.isNil)(metadata))
|
|
12
12
|
.toArray();
|
|
13
13
|
}
|
|
14
14
|
*getAllFilteredMethodNames(prototype) {
|
|
@@ -17,10 +17,10 @@ class MetadataScanner {
|
|
|
17
17
|
if (descriptor.set || descriptor.get) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
|
-
return !shared_utils_1.isConstructor(prop) && shared_utils_1.isFunction(prototype[prop]);
|
|
20
|
+
return !(0, shared_utils_1.isConstructor)(prop) && (0, shared_utils_1.isFunction)(prototype[prop]);
|
|
21
21
|
};
|
|
22
22
|
do {
|
|
23
|
-
yield* iterare_1.iterate(Object.getOwnPropertyNames(prototype))
|
|
23
|
+
yield* (0, iterare_1.iterate)(Object.getOwnPropertyNames(prototype))
|
|
24
24
|
.filter(isMethod)
|
|
25
25
|
.toArray();
|
|
26
26
|
} while ((prototype = Reflect.getPrototypeOf(prototype)) &&
|
package/middleware/builder.js
CHANGED
|
@@ -11,7 +11,7 @@ class MiddlewareBuilder {
|
|
|
11
11
|
this.middlewareCollection = new Set();
|
|
12
12
|
}
|
|
13
13
|
apply(...middleware) {
|
|
14
|
-
return new MiddlewareBuilder.ConfigProxy(this, dependencies_decorator_1.flatten(middleware));
|
|
14
|
+
return new MiddlewareBuilder.ConfigProxy(this, (0, dependencies_decorator_1.flatten)(middleware));
|
|
15
15
|
}
|
|
16
16
|
build() {
|
|
17
17
|
return [...this.middlewareCollection];
|
|
@@ -38,7 +38,7 @@ MiddlewareBuilder.ConfigProxy = class {
|
|
|
38
38
|
const { middlewareCollection } = this.builder;
|
|
39
39
|
const forRoutes = this.getRoutesFlatList(routes);
|
|
40
40
|
const configuration = {
|
|
41
|
-
middleware: utils_1.filterMiddleware(this.middleware, this.excludedRoutes, this.builder.getHttpAdapter()),
|
|
41
|
+
middleware: (0, utils_1.filterMiddleware)(this.middleware, this.excludedRoutes, this.builder.getHttpAdapter()),
|
|
42
42
|
forRoutes,
|
|
43
43
|
};
|
|
44
44
|
middlewareCollection.add(configuration);
|
|
@@ -46,7 +46,7 @@ MiddlewareBuilder.ConfigProxy = class {
|
|
|
46
46
|
}
|
|
47
47
|
getRoutesFlatList(routes) {
|
|
48
48
|
const { routesMapper } = this.builder;
|
|
49
|
-
return iterare_1.iterate(routes)
|
|
49
|
+
return (0, iterare_1.iterate)(routes)
|
|
50
50
|
.map(route => routesMapper.mapRouteToRouteInfo(route))
|
|
51
51
|
.flatten()
|
|
52
52
|
.toArray();
|
package/middleware/container.js
CHANGED
|
@@ -26,7 +26,7 @@ class MiddlewareContainer {
|
|
|
26
26
|
const insertMiddleware = (metatype) => {
|
|
27
27
|
const token = metatype;
|
|
28
28
|
middleware.set(token, new instance_wrapper_1.InstanceWrapper({
|
|
29
|
-
scope: get_class_scope_1.getClassScope(metatype),
|
|
29
|
+
scope: (0, get_class_scope_1.getClassScope)(metatype),
|
|
30
30
|
name: token,
|
|
31
31
|
metatype,
|
|
32
32
|
token,
|
|
@@ -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) {
|