@nestjs/core 7.6.4 → 7.6.8
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/LICENSE +1 -1
- package/Readme.md +13 -3
- package/adapters/http-adapter.d.ts +5 -2
- package/adapters/http-adapter.js +6 -0
- package/injector/compiler.d.ts +2 -2
- package/injector/compiler.js +2 -3
- package/nest-application-context.d.ts +4 -3
- package/nest-application-context.js +8 -5
- package/nest-application.d.ts +2 -2
- package/nest-application.js +3 -2
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(The MIT License)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2017-
|
|
3
|
+
Copyright (c) 2017-2021 Kamil Mysliwiec <https://kamilmysliwiec.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/Readme.md
CHANGED
|
@@ -56,16 +56,21 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
56
56
|
|
|
57
57
|
#### Principal Sponsors
|
|
58
58
|
<table style="text-align:center;"><tr><td>
|
|
59
|
-
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td
|
|
60
|
-
<
|
|
59
|
+
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
|
60
|
+
<td>
|
|
61
|
+
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
|
61
62
|
</tr></table>
|
|
62
63
|
|
|
64
|
+
#### Gold Sponsors
|
|
65
|
+
|
|
66
|
+
<table style="text-align:center;"><tr><td>
|
|
67
|
+
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td></tr></table>
|
|
68
|
+
|
|
63
69
|
#### Silver Sponsors
|
|
64
70
|
|
|
65
71
|
<table style="text-align:center;"><tr><td>
|
|
66
72
|
<a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
|
|
67
73
|
<a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
|
|
68
|
-
<a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="170" valign="middle" /></a> </td><td>
|
|
69
74
|
<a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
|
|
70
75
|
<a href="http://www.meetdandy.com" target="_blank"><img src="https://nestjs.com/img/dandy-wide-logo.png" width="150" valign="middle" /></td></tr></table>
|
|
71
76
|
|
|
@@ -90,6 +95,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
90
95
|
<td align="center" valign="middle">
|
|
91
96
|
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
|
92
97
|
<td align="center" valign="middle"><a href="https://sanyodigital.com/" target="_blank"><img src="https://nestjs.com/img/sanyo-digital.png" width="130" valign="middle" /></a></td></tr><tr><td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/vpn-review-logo.png" width="85" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/lambda-it-logo.svg" width="115" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://pickwriters.com/top-10-translation-services" target="_blank"><img src="https://nestjs.com/img/pickwriters-logo.png" width="40" valign="middle" /></a></td><td align="center" valign="middle"><a href="https://thewordpoint.com/services/localization" target="_blank"><img src="https://nestjs.com/img/thewordpoint-logo.png" width="40" valign="middle" /></a></td>
|
|
98
|
+
<td align="center" valign="middle"><a href="https://streamat.se/" target="_blank"><img src="https://nestjs.com/img/streamat-logo.png" width="120" valign="middle" /></a></td>
|
|
99
|
+
<td align="center" valign="middle"><a href="https://filmen.nu/" target="_blank"><img src="https://nestjs.com/img/filmen-logo.png" width="120" valign="middle" /></a></td></tr><tr>
|
|
100
|
+
<td align="center" valign="middle"><a href="https://meercode.io/" target="_blank"><img src="https://nestjs.com/img/meercode-logo.png" width="60" valign="middle" /></a></td>
|
|
101
|
+
<td align="center" valign="middle"><a href="https://www.najlepszeplatformyforex.pl/blog/broker-xtb/" target="_blank"><img src="https://nestjs.com/img/npf-logo.jpg" width="200" valign="middle" /></a></td>
|
|
102
|
+
<td align="center" valign="middle"><a href="https://thestandarddaily.com/" target="_blank"><img src="https://nestjs.com/img/the-standard-daily-logo.png" width="180" valign="middle" /></a></td>
|
|
93
103
|
</tr></table>
|
|
94
104
|
|
|
95
105
|
## Backers
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpServer, RequestMethod } from '@nestjs/common';
|
|
2
2
|
import { RequestHandler } from '@nestjs/common/interfaces';
|
|
3
|
-
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
|
3
|
+
import { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/interfaces/external/cors-options.interface';
|
|
4
4
|
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
|
5
5
|
/**
|
|
6
6
|
* @publicApi
|
|
@@ -9,6 +9,9 @@ export declare abstract class AbstractHttpAdapter<TServer = any, TRequest = any,
|
|
|
9
9
|
protected readonly instance: any;
|
|
10
10
|
protected httpServer: TServer;
|
|
11
11
|
constructor(instance: any);
|
|
12
|
+
all(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
13
|
+
all(handler: RequestHandler<TRequest, TResponse>): any;
|
|
14
|
+
setBaseViewsDir?(path: string | string[]): this;
|
|
12
15
|
init(): Promise<void>;
|
|
13
16
|
use(...args: any[]): any;
|
|
14
17
|
get(handler: RequestHandler): any;
|
|
@@ -45,7 +48,7 @@ export declare abstract class AbstractHttpAdapter<TServer = any, TRequest = any,
|
|
|
45
48
|
abstract setNotFoundHandler(handler: Function, prefix?: string): any;
|
|
46
49
|
abstract setHeader(response: any, name: string, value: string): any;
|
|
47
50
|
abstract registerParserMiddleware(prefix?: string): any;
|
|
48
|
-
abstract enableCors(options: CorsOptions
|
|
51
|
+
abstract enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>, prefix?: string): any;
|
|
49
52
|
abstract createMiddlewareFactory(requestMethod: RequestMethod): ((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>;
|
|
50
53
|
abstract getType(): string;
|
|
51
54
|
}
|
package/adapters/http-adapter.js
CHANGED
|
@@ -8,6 +8,12 @@ class AbstractHttpAdapter {
|
|
|
8
8
|
constructor(instance) {
|
|
9
9
|
this.instance = instance;
|
|
10
10
|
}
|
|
11
|
+
all(path, handler) {
|
|
12
|
+
throw new Error('Method not implemented.');
|
|
13
|
+
}
|
|
14
|
+
setBaseViewsDir(path) {
|
|
15
|
+
throw new Error('Method not implemented.');
|
|
16
|
+
}
|
|
11
17
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
12
18
|
async init() { }
|
|
13
19
|
use(...args) {
|
package/injector/compiler.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ export declare class ModuleCompiler {
|
|
|
9
9
|
private readonly moduleTokenFactory;
|
|
10
10
|
constructor(moduleTokenFactory?: ModuleTokenFactory);
|
|
11
11
|
compile(metatype: Type<any> | DynamicModule | Promise<DynamicModule>): Promise<ModuleFactory>;
|
|
12
|
-
extractMetadata(metatype: Type<any> | DynamicModule
|
|
12
|
+
extractMetadata(metatype: Type<any> | DynamicModule): {
|
|
13
13
|
type: Type<any>;
|
|
14
14
|
dynamicMetadata?: Partial<DynamicModule> | undefined;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
isDynamicModule(module: Type<any> | DynamicModule): module is DynamicModule;
|
|
17
17
|
}
|
package/injector/compiler.js
CHANGED
|
@@ -8,12 +8,11 @@ class ModuleCompiler {
|
|
|
8
8
|
this.moduleTokenFactory = moduleTokenFactory;
|
|
9
9
|
}
|
|
10
10
|
async compile(metatype) {
|
|
11
|
-
const { type, dynamicMetadata } =
|
|
11
|
+
const { type, dynamicMetadata } = this.extractMetadata(await metatype);
|
|
12
12
|
const token = this.moduleTokenFactory.create(type, dynamicMetadata);
|
|
13
13
|
return { type, dynamicMetadata, token };
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
metatype = await metatype;
|
|
15
|
+
extractMetadata(metatype) {
|
|
17
16
|
if (!this.isDynamicModule(metatype)) {
|
|
18
17
|
return { type: metatype };
|
|
19
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INestApplicationContext, LoggerService, LogLevel, ShutdownSignal } from '@nestjs/common';
|
|
2
|
-
import { Abstract } from '@nestjs/common/interfaces';
|
|
2
|
+
import { Abstract, DynamicModule } from '@nestjs/common/interfaces';
|
|
3
3
|
import { Type } from '@nestjs/common/interfaces/type.interface';
|
|
4
4
|
import { ContextId } from './injector';
|
|
5
5
|
import { NestContainer } from './injector/container';
|
|
@@ -14,13 +14,14 @@ export declare class NestApplicationContext implements INestApplicationContext {
|
|
|
14
14
|
private contextModule;
|
|
15
15
|
protected isInitialized: boolean;
|
|
16
16
|
protected readonly injector: Injector;
|
|
17
|
-
private shutdownCleanupRef?;
|
|
18
17
|
private readonly activeShutdownSignals;
|
|
18
|
+
private readonly moduleCompiler;
|
|
19
|
+
private shutdownCleanupRef?;
|
|
19
20
|
private _instanceLinksHost;
|
|
20
21
|
private get instanceLinksHost();
|
|
21
22
|
constructor(container: NestContainer, scope?: Type<any>[], contextModule?: Module);
|
|
22
23
|
selectContextModule(): void;
|
|
23
|
-
select<T>(moduleType: Type<T>): INestApplicationContext;
|
|
24
|
+
select<T>(moduleType: Type<T> | DynamicModule): INestApplicationContext;
|
|
24
25
|
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, options?: {
|
|
25
26
|
strict: boolean;
|
|
26
27
|
}): TResult;
|
|
@@ -11,6 +11,7 @@ const unknown_element_exception_1 = require("./errors/exceptions/unknown-element
|
|
|
11
11
|
const unknown_module_exception_1 = require("./errors/exceptions/unknown-module.exception");
|
|
12
12
|
const helpers_1 = require("./helpers");
|
|
13
13
|
const hooks_1 = require("./hooks");
|
|
14
|
+
const compiler_1 = require("./injector/compiler");
|
|
14
15
|
const injector_1 = require("./injector/injector");
|
|
15
16
|
const instance_links_host_1 = require("./injector/instance-links-host");
|
|
16
17
|
/**
|
|
@@ -24,6 +25,7 @@ class NestApplicationContext {
|
|
|
24
25
|
this.isInitialized = false;
|
|
25
26
|
this.injector = new injector_1.Injector();
|
|
26
27
|
this.activeShutdownSignals = new Array();
|
|
28
|
+
this.moduleCompiler = new compiler_1.ModuleCompiler();
|
|
27
29
|
}
|
|
28
30
|
get instanceLinksHost() {
|
|
29
31
|
if (!this._instanceLinksHost) {
|
|
@@ -36,12 +38,13 @@ class NestApplicationContext {
|
|
|
36
38
|
this.contextModule = modules.next().value;
|
|
37
39
|
}
|
|
38
40
|
select(moduleType) {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const scope = this.scope.concat(
|
|
41
|
+
const modulesContainer = this.container.getModules();
|
|
42
|
+
const contextModuleCtor = this.contextModule.metatype;
|
|
43
|
+
const scope = this.scope.concat(contextModuleCtor);
|
|
42
44
|
const moduleTokenFactory = this.container.getModuleTokenFactory();
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
+
const { type, dynamicMetadata } = this.moduleCompiler.extractMetadata(moduleType);
|
|
46
|
+
const token = moduleTokenFactory.create(type, dynamicMetadata);
|
|
47
|
+
const selectedModule = modulesContainer.get(token);
|
|
45
48
|
if (!selectedModule) {
|
|
46
49
|
throw new unknown_module_exception_1.UnknownModuleException();
|
|
47
50
|
}
|
package/nest-application.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CanActivate, ExceptionFilter, HttpServer, INestApplication, INestMicroservice, NestHybridApplicationOptions, NestInterceptor, PipeTransform, WebSocketAdapter } from '@nestjs/common';
|
|
2
|
-
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
|
2
|
+
import { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/interfaces/external/cors-options.interface';
|
|
3
3
|
import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
|
4
4
|
import { AbstractHttpAdapter } from './adapters';
|
|
5
5
|
import { ApplicationConfig } from './application-config';
|
|
@@ -40,7 +40,7 @@ export declare class NestApplication extends NestApplicationContext implements I
|
|
|
40
40
|
startAllMicroservices(callback?: () => void): this;
|
|
41
41
|
startAllMicroservicesAsync(): Promise<void>;
|
|
42
42
|
use(...args: [any, any?]): this;
|
|
43
|
-
enableCors(options?: CorsOptions): void;
|
|
43
|
+
enableCors(options?: CorsOptions | CorsOptionsDelegate<any>): void;
|
|
44
44
|
listen(port: number | string, callback?: () => void): Promise<any>;
|
|
45
45
|
listen(port: number | string, hostname: string, callback?: () => void): Promise<any>;
|
|
46
46
|
listenAsync(port: number | string, hostname?: string): Promise<any>;
|
package/nest-application.js
CHANGED
|
@@ -56,8 +56,9 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
|
|
|
56
56
|
if (!this.appOptions || !this.appOptions.cors) {
|
|
57
57
|
return undefined;
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
const passCustomOptions = shared_utils_1.isObject(this.appOptions.cors) ||
|
|
60
|
+
typeof this.appOptions.cors === 'function';
|
|
61
|
+
if (!passCustomOptions) {
|
|
61
62
|
return this.enableCors();
|
|
62
63
|
}
|
|
63
64
|
return this.enableCors(this.appOptions.cors);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.8",
|
|
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.0.7",
|
|
32
32
|
"iterare": "1.2.1",
|
|
33
|
-
"object-hash": "2.
|
|
33
|
+
"object-hash": "2.1.1",
|
|
34
34
|
"path-to-regexp": "3.2.0",
|
|
35
|
-
"tslib": "2.0
|
|
35
|
+
"tslib": "2.1.0",
|
|
36
36
|
"uuid": "8.3.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nestjs/common": "7.6.
|
|
39
|
+
"@nestjs/common": "7.6.8"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^7.0.0",
|