@nestjs/core 7.6.5 → 7.6.9
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/nest-application.d.ts +2 -2
- package/nest-application.js +3 -2
- package/package.json +3 -3
- package/router/router-explorer.d.ts +2 -2
- package/router/router-explorer.js +16 -7
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/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.9",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"iterare": "1.2.1",
|
|
33
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.9"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^7.0.0",
|
|
@@ -27,11 +27,11 @@ export declare class RouterExplorer {
|
|
|
27
27
|
private readonly logger;
|
|
28
28
|
private readonly exceptionFiltersCache;
|
|
29
29
|
constructor(metadataScanner: MetadataScanner, container: NestContainer, injector?: Injector, routerProxy?: RouterProxy, exceptionsFilter?: ExceptionsFilter, config?: ApplicationConfig);
|
|
30
|
-
explore<T extends HttpServer = any>(instanceWrapper: InstanceWrapper, module: string, applicationRef: T, basePath: string, host: string): void;
|
|
30
|
+
explore<T extends HttpServer = any>(instanceWrapper: InstanceWrapper, module: string, applicationRef: T, basePath: string, host: string | string[]): void;
|
|
31
31
|
extractRouterPath(metatype: Type<Controller>, prefix?: string): string[];
|
|
32
32
|
scanForPaths(instance: Controller, prototype?: object): RoutePathProperties[];
|
|
33
33
|
exploreMethodMetadata(instance: Controller, prototype: object, methodName: string): RoutePathProperties;
|
|
34
|
-
applyPathsToRouterProxy<T extends HttpServer>(router: T, routePaths: RoutePathProperties[], instanceWrapper: InstanceWrapper, moduleKey: string, basePath: string, host: string): void;
|
|
34
|
+
applyPathsToRouterProxy<T extends HttpServer>(router: T, routePaths: RoutePathProperties[], instanceWrapper: InstanceWrapper, moduleKey: string, basePath: string, host: string | string[]): void;
|
|
35
35
|
stripEndSlash(str: string): string;
|
|
36
36
|
private applyCallbackToRouter;
|
|
37
37
|
private applyHostFilter;
|
|
@@ -108,18 +108,27 @@ class RouterExplorer {
|
|
|
108
108
|
return handler;
|
|
109
109
|
}
|
|
110
110
|
const httpAdapterRef = this.container.getHttpAdapterRef();
|
|
111
|
-
const
|
|
112
|
-
const
|
|
111
|
+
const hosts = Array.isArray(host) ? host : [host];
|
|
112
|
+
const hostRegExps = hosts.map((host) => {
|
|
113
|
+
const keys = [];
|
|
114
|
+
const regexp = pathToRegexp(host, keys);
|
|
115
|
+
return { regexp, keys };
|
|
116
|
+
});
|
|
117
|
+
const unsupportedFilteringErrorMessage = Array.isArray(host)
|
|
118
|
+
? `HTTP adapter does not support filtering on hosts: ["${host.join('", "')}"]`
|
|
119
|
+
: `HTTP adapter does not support filtering on host: "${host}"`;
|
|
113
120
|
return (req, res, next) => {
|
|
114
121
|
req.hosts = {};
|
|
115
122
|
const hostname = httpAdapterRef.getRequestHostname(req) || '';
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
for (const exp of hostRegExps) {
|
|
124
|
+
const match = hostname.match(exp.regexp);
|
|
125
|
+
if (match) {
|
|
126
|
+
exp.keys.forEach((key, i) => (req.hosts[key.name] = match[i + 1]));
|
|
127
|
+
return handler(req, res, next);
|
|
128
|
+
}
|
|
120
129
|
}
|
|
121
130
|
if (!next) {
|
|
122
|
-
throw new exceptions_1.InternalServerErrorException(
|
|
131
|
+
throw new exceptions_1.InternalServerErrorException(unsupportedFilteringErrorMessage);
|
|
123
132
|
}
|
|
124
133
|
return next();
|
|
125
134
|
};
|