@nestjs/common 8.4.4 → 8.4.7
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 +6 -4
- package/http/interfaces/index.d.ts +1 -0
- package/http/interfaces/index.js +1 -0
- package/http/interfaces/raw-body-request.interface.d.ts +4 -0
- package/http/interfaces/raw-body-request.interface.js +2 -0
- package/interfaces/http/http-server.interface.d.ts +1 -1
- package/interfaces/nest-application-options.interface.d.ts +4 -0
- package/package.json +3 -3
- package/pipes/parse-bool.pipe.d.ts +12 -0
- package/pipes/parse-bool.pipe.js +18 -2
- package/pipes/parse-float.pipe.d.ts +5 -0
- package/pipes/parse-float.pipe.js +10 -4
- package/pipes/parse-int.pipe.d.ts +5 -0
- package/pipes/parse-int.pipe.js +10 -4
- package/pipes/validation.pipe.d.ts +1 -1
- package/pipes/validation.pipe.js +15 -4
package/Readme.md
CHANGED
|
@@ -65,18 +65,20 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
65
65
|
<td>
|
|
66
66
|
<a href="https://nx.dev" target="_blank"><img src="https://nestjs.com/img/nx-logo.png" height="45" valign="middle" /></a></td>
|
|
67
67
|
<td>
|
|
68
|
-
<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>
|
|
68
|
+
<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><td>
|
|
69
|
+
<a href="https://amplication.com/" target="_blank"><img src="https://nestjs.com/img/amplication-logo.svg" width="190" valign="middle" /></a></td>
|
|
69
70
|
</tr></table>
|
|
70
71
|
|
|
71
72
|
#### Gold Sponsors
|
|
72
73
|
|
|
73
74
|
<table style="text-align:center;"><tr><td>
|
|
74
|
-
|
|
75
|
-
<a href="https://weld.app/" target="_blank"><img src="https://nestjs.com/img/weld-logo.svg" width="150" valign="middle" /></a></td>
|
|
75
|
+
<a href="https://weld.app/" target="_blank"><img src="https://nestjs.com/img/weld-logo.svg" width="140" valign="middle" /></a></td>
|
|
76
76
|
<td>
|
|
77
77
|
<a href="https://intrinsic.ventures/" target="_blank"><img src="https://nestjs.com/img/intrinisic-logo.png" width="210" valign="middle" /></a></td>
|
|
78
78
|
<td>
|
|
79
|
-
<a href="https://jetbrains.com/" target="_blank"><img src="https://nestjs.com/img/jetbrains-logo.svg" width="110" valign="middle" /></a></td
|
|
79
|
+
<a href="https://jetbrains.com/" target="_blank"><img src="https://nestjs.com/img/jetbrains-logo.svg" width="110" valign="middle" /></a></td><td>
|
|
80
|
+
<a href="https://snyk.co/nestjs" target="_blank"><img src="https://nestjs.com/img/snyk-logo-black.png" width="185" valign="middle" /></a></td><td>
|
|
81
|
+
<a href="https://fuseautotech.com/" target="_blank"><img src="https://nestjs.com/img/fuse-logo.svg" width="105" valign="middle" /></a></td></</tr></table>
|
|
80
82
|
|
|
81
83
|
#### Silver Sponsors
|
|
82
84
|
|
package/http/interfaces/index.js
CHANGED
|
@@ -40,7 +40,7 @@ export interface HttpServer<TRequest = any, TResponse = any> {
|
|
|
40
40
|
getRequestMethod?(request: TRequest): string;
|
|
41
41
|
getRequestUrl?(request: TRequest): string;
|
|
42
42
|
getInstance(): any;
|
|
43
|
-
registerParserMiddleware(): any;
|
|
43
|
+
registerParserMiddleware(...args: any[]): any;
|
|
44
44
|
enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>): any;
|
|
45
45
|
getHttpServer(): any;
|
|
46
46
|
initHttpServer(options: NestApplicationOptions): void;
|
|
@@ -17,4 +17,8 @@ export interface NestApplicationOptions extends NestApplicationContextOptions {
|
|
|
17
17
|
* Set of configurable HTTPS options
|
|
18
18
|
*/
|
|
19
19
|
httpsOptions?: HttpsOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to register the raw request body on the request. Use `req.rawBody`.
|
|
22
|
+
*/
|
|
23
|
+
rawBody?: boolean;
|
|
20
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/common",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.7",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"homepage": "https://nestjs.com",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"axios": "0.
|
|
20
|
+
"axios": "0.27.2",
|
|
21
21
|
"iterare": "1.2.1",
|
|
22
|
-
"tslib": "2.
|
|
22
|
+
"tslib": "2.4.0",
|
|
23
23
|
"uuid": "8.3.2"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
@@ -22,4 +22,16 @@ export declare class ParseBoolPipe implements PipeTransform<string | boolean, Pr
|
|
|
22
22
|
* @param metadata contains metadata about the currently processed route argument
|
|
23
23
|
*/
|
|
24
24
|
transform(value: string | boolean, metadata: ArgumentMetadata): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* @param value currently processed route argument
|
|
27
|
+
* @returns `true` if `value` is said 'true', ie., if it is equal to the boolean
|
|
28
|
+
* `true` or the string `"true"`
|
|
29
|
+
*/
|
|
30
|
+
protected isTrue(value: string | boolean): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* @param value currently processed route argument
|
|
33
|
+
* @returns `true` if `value` is said 'false', ie., if it is equal to the boolean
|
|
34
|
+
* `false` or the string `"false"`
|
|
35
|
+
*/
|
|
36
|
+
protected isFalse(value: string | boolean): boolean;
|
|
25
37
|
}
|
package/pipes/parse-bool.pipe.js
CHANGED
|
@@ -29,14 +29,30 @@ let ParseBoolPipe = class ParseBoolPipe {
|
|
|
29
29
|
* @param metadata contains metadata about the currently processed route argument
|
|
30
30
|
*/
|
|
31
31
|
async transform(value, metadata) {
|
|
32
|
-
if (value
|
|
32
|
+
if (this.isTrue(value)) {
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
|
-
if (value
|
|
35
|
+
if (this.isFalse(value)) {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
38
|
throw this.exceptionFactory('Validation failed (boolean string is expected)');
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* @param value currently processed route argument
|
|
42
|
+
* @returns `true` if `value` is said 'true', ie., if it is equal to the boolean
|
|
43
|
+
* `true` or the string `"true"`
|
|
44
|
+
*/
|
|
45
|
+
isTrue(value) {
|
|
46
|
+
return value === true || value === 'true';
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @param value currently processed route argument
|
|
50
|
+
* @returns `true` if `value` is said 'false', ie., if it is equal to the boolean
|
|
51
|
+
* `false` or the string `"false"`
|
|
52
|
+
*/
|
|
53
|
+
isFalse(value) {
|
|
54
|
+
return value === false || value === 'false';
|
|
55
|
+
}
|
|
40
56
|
};
|
|
41
57
|
ParseBoolPipe = tslib_1.__decorate([
|
|
42
58
|
(0, injectable_decorator_1.Injectable)(),
|
|
@@ -23,4 +23,9 @@ export declare class ParseFloatPipe implements PipeTransform<string> {
|
|
|
23
23
|
* @param metadata contains metadata about the currently processed route argument
|
|
24
24
|
*/
|
|
25
25
|
transform(value: string, metadata: ArgumentMetadata): Promise<number>;
|
|
26
|
+
/**
|
|
27
|
+
* @param value currently processed route argument
|
|
28
|
+
* @returns `true` if `value` is a valid float number
|
|
29
|
+
*/
|
|
30
|
+
protected isNumeric(value: string): boolean;
|
|
26
31
|
}
|
|
@@ -27,14 +27,20 @@ let ParseFloatPipe = class ParseFloatPipe {
|
|
|
27
27
|
* @param metadata contains metadata about the currently processed route argument
|
|
28
28
|
*/
|
|
29
29
|
async transform(value, metadata) {
|
|
30
|
-
|
|
31
|
-
!isNaN(parseFloat(value)) &&
|
|
32
|
-
isFinite(value);
|
|
33
|
-
if (!isNumeric) {
|
|
30
|
+
if (!this.isNumeric(value)) {
|
|
34
31
|
throw this.exceptionFactory('Validation failed (numeric string is expected)');
|
|
35
32
|
}
|
|
36
33
|
return parseFloat(value);
|
|
37
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @param value currently processed route argument
|
|
37
|
+
* @returns `true` if `value` is a valid float number
|
|
38
|
+
*/
|
|
39
|
+
isNumeric(value) {
|
|
40
|
+
return (['string', 'number'].includes(typeof value) &&
|
|
41
|
+
!isNaN(parseFloat(value)) &&
|
|
42
|
+
isFinite(value));
|
|
43
|
+
}
|
|
38
44
|
};
|
|
39
45
|
ParseFloatPipe = tslib_1.__decorate([
|
|
40
46
|
(0, index_1.Injectable)(),
|
|
@@ -22,4 +22,9 @@ export declare class ParseIntPipe implements PipeTransform<string> {
|
|
|
22
22
|
* @param metadata contains metadata about the currently processed route argument
|
|
23
23
|
*/
|
|
24
24
|
transform(value: string, metadata: ArgumentMetadata): Promise<number>;
|
|
25
|
+
/**
|
|
26
|
+
* @param value currently processed route argument
|
|
27
|
+
* @returns `true` if `value` is a valid integer number
|
|
28
|
+
*/
|
|
29
|
+
protected isNumeric(value: string): boolean;
|
|
25
30
|
}
|
package/pipes/parse-int.pipe.js
CHANGED
|
@@ -29,14 +29,20 @@ let ParseIntPipe = class ParseIntPipe {
|
|
|
29
29
|
* @param metadata contains metadata about the currently processed route argument
|
|
30
30
|
*/
|
|
31
31
|
async transform(value, metadata) {
|
|
32
|
-
|
|
33
|
-
/^-?\d+$/.test(value) &&
|
|
34
|
-
isFinite(value);
|
|
35
|
-
if (!isNumeric) {
|
|
32
|
+
if (!this.isNumeric(value)) {
|
|
36
33
|
throw this.exceptionFactory('Validation failed (numeric string is expected)');
|
|
37
34
|
}
|
|
38
35
|
return parseInt(value, 10);
|
|
39
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* @param value currently processed route argument
|
|
39
|
+
* @returns `true` if `value` is a valid integer number
|
|
40
|
+
*/
|
|
41
|
+
isNumeric(value) {
|
|
42
|
+
return (['string', 'number'].includes(typeof value) &&
|
|
43
|
+
/^-?\d+$/.test(value) &&
|
|
44
|
+
isFinite(value));
|
|
45
|
+
}
|
|
40
46
|
};
|
|
41
47
|
ParseIntPipe = tslib_1.__decorate([
|
|
42
48
|
(0, injectable_decorator_1.Injectable)(),
|
|
@@ -34,7 +34,7 @@ export declare class ValidationPipe implements PipeTransform<any> {
|
|
|
34
34
|
protected toValidate(metadata: ArgumentMetadata): boolean;
|
|
35
35
|
protected transformPrimitive(value: any, metadata: ArgumentMetadata): any;
|
|
36
36
|
protected toEmptyIfNil<T = any, R = any>(value: T): R | {};
|
|
37
|
-
protected stripProtoKeys(value:
|
|
37
|
+
protected stripProtoKeys(value: any): void;
|
|
38
38
|
protected isPrimitive(value: unknown): boolean;
|
|
39
39
|
protected validate(object: object, validatorOptions?: ValidatorOptions): Promise<ValidationError[]> | ValidationError[];
|
|
40
40
|
protected flattenValidationErrors(validationErrors: ValidationError[]): string[];
|
package/pipes/validation.pipe.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ValidationPipe = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const iterare_1 = require("iterare");
|
|
6
|
+
const util_1 = require("util");
|
|
6
7
|
const decorators_1 = require("../decorators");
|
|
7
8
|
const core_1 = require("../decorators/core");
|
|
8
9
|
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
@@ -118,11 +119,21 @@ let ValidationPipe = class ValidationPipe {
|
|
|
118
119
|
return (0, shared_utils_1.isNil)(value) ? {} : value;
|
|
119
120
|
}
|
|
120
121
|
stripProtoKeys(value) {
|
|
122
|
+
if (value == null ||
|
|
123
|
+
typeof value !== 'object' ||
|
|
124
|
+
util_1.types.isTypedArray(value)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (Array.isArray(value)) {
|
|
128
|
+
for (const v of value) {
|
|
129
|
+
this.stripProtoKeys(v);
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
121
133
|
delete value.__proto__;
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.forEach(key => this.stripProtoKeys(value[key]));
|
|
134
|
+
for (const key in value) {
|
|
135
|
+
this.stripProtoKeys(value[key]);
|
|
136
|
+
}
|
|
126
137
|
}
|
|
127
138
|
isPrimitive(value) {
|
|
128
139
|
return ['number', 'boolean', 'string'].includes(typeof value);
|