@nestjs/common 5.5.0-0 → 5.6.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 +3 -5
- package/http/http.module.js +5 -0
- package/interfaces/microservices/microservice-configuration.interface.d.ts +3 -0
- package/interfaces/nest-application-context.interface.d.ts +2 -1
- package/package.json +1 -1
- package/pipes/validation.pipe.d.ts +3 -0
- package/pipes/validation.pipe.js +4 -3
package/Readme.md
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
|
17
17
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#8" alt="Coverage" /></a>
|
|
18
18
|
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
|
19
|
+
<a href="https://discord.gg/G7Qnnhy"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
|
19
20
|
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
20
21
|
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
21
22
|
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
|
@@ -48,13 +49,10 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
48
49
|
|
|
49
50
|
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="320" /></a>
|
|
50
51
|
|
|
51
|
-
#### Gold Sponsors
|
|
52
|
-
|
|
53
|
-
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="220" /></a>
|
|
54
|
-
|
|
55
52
|
#### Silver Sponsors
|
|
56
53
|
<a href="https://neoteric.eu/"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" /></a>
|
|
57
|
-
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="bottom" height="95" /></a> <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /> </a>
|
|
54
|
+
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="bottom" height="95" /></a> <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /> </a>
|
|
55
|
+
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="150" /></a>
|
|
58
56
|
|
|
59
57
|
#### Sponsors
|
|
60
58
|
|
package/http/http.module.js
CHANGED
|
@@ -33,6 +33,11 @@ let HttpModule = HttpModule_1 = class HttpModule {
|
|
|
33
33
|
imports: options.imports,
|
|
34
34
|
providers: [
|
|
35
35
|
...this.createAsyncProviders(options),
|
|
36
|
+
{
|
|
37
|
+
provide: http_constants_1.AXIOS_INSTANCE_TOKEN,
|
|
38
|
+
useFactory: (config) => axios_1.default.create(config),
|
|
39
|
+
inject: [http_constants_1.HTTP_MODULE_OPTIONS],
|
|
40
|
+
},
|
|
36
41
|
{
|
|
37
42
|
provide: http_constants_1.HTTP_MODULE_ID,
|
|
38
43
|
useValue: random_string_generator_util_1.randomStringGenerator(),
|
|
@@ -10,6 +10,8 @@ export interface GrpcOptions {
|
|
|
10
10
|
transport?: Transport.GRPC;
|
|
11
11
|
options: {
|
|
12
12
|
url?: string;
|
|
13
|
+
maxSendMessageLength?: number;
|
|
14
|
+
maxReceiveMessageLength?: number;
|
|
13
15
|
credentials?: any;
|
|
14
16
|
protoPath: string;
|
|
15
17
|
package: string;
|
|
@@ -63,6 +65,7 @@ export interface NatsOptions {
|
|
|
63
65
|
reconnectTimeWait?: number;
|
|
64
66
|
servers?: string[];
|
|
65
67
|
tls?: any;
|
|
68
|
+
queue?: string;
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
71
|
export interface RmqOptions {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LoggerService } from '../services/logger.service';
|
|
2
|
+
import { Abstract } from './abstract.interface';
|
|
2
3
|
import { Type } from './type.interface';
|
|
3
4
|
export interface INestApplicationContext {
|
|
4
5
|
/**
|
|
@@ -10,7 +11,7 @@ export interface INestApplicationContext {
|
|
|
10
11
|
* Retrieves an instance of either injectable or controller available anywhere, otherwise, throws exception.
|
|
11
12
|
* @returns {TResult}
|
|
12
13
|
*/
|
|
13
|
-
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | string | symbol, options?: {
|
|
14
|
+
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, options?: {
|
|
14
15
|
strict: boolean;
|
|
15
16
|
}): TResult;
|
|
16
17
|
/**
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { ArgumentMetadata, ValidationError } from '../index';
|
|
2
2
|
import { ValidatorOptions } from '../interfaces/external/validator-options.interface';
|
|
3
|
+
import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface';
|
|
3
4
|
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
4
5
|
export interface ValidationPipeOptions extends ValidatorOptions {
|
|
5
6
|
transform?: boolean;
|
|
6
7
|
disableErrorMessages?: boolean;
|
|
8
|
+
transformOptions?: ClassTransformOptions;
|
|
7
9
|
exceptionFactory?: (errors: ValidationError[]) => any;
|
|
8
10
|
}
|
|
9
11
|
export declare class ValidationPipe implements PipeTransform<any> {
|
|
10
12
|
protected isTransformEnabled: boolean;
|
|
11
13
|
protected isDetailedOutputDisabled?: boolean;
|
|
12
14
|
protected validatorOptions: ValidatorOptions;
|
|
15
|
+
protected transformOptions: ClassTransformOptions;
|
|
13
16
|
protected exceptionFactory: (errors: ValidationError[]) => any;
|
|
14
17
|
constructor(options?: ValidationPipeOptions);
|
|
15
18
|
transform(value: any, metadata: ArgumentMetadata): Promise<any>;
|
package/pipes/validation.pipe.js
CHANGED
|
@@ -31,9 +31,10 @@ let classTransformer = {};
|
|
|
31
31
|
let ValidationPipe = class ValidationPipe {
|
|
32
32
|
constructor(options) {
|
|
33
33
|
options = options || {};
|
|
34
|
-
const { transform, disableErrorMessages } = options, validatorOptions = __rest(options, ["transform", "disableErrorMessages"]);
|
|
34
|
+
const { transform, disableErrorMessages, transformOptions } = options, validatorOptions = __rest(options, ["transform", "disableErrorMessages", "transformOptions"]);
|
|
35
35
|
this.isTransformEnabled = !!transform;
|
|
36
36
|
this.validatorOptions = validatorOptions;
|
|
37
|
+
this.transformOptions = transformOptions;
|
|
37
38
|
this.isDetailedOutputDisabled = disableErrorMessages;
|
|
38
39
|
this.exceptionFactory =
|
|
39
40
|
options.exceptionFactory ||
|
|
@@ -47,7 +48,7 @@ let ValidationPipe = class ValidationPipe {
|
|
|
47
48
|
if (!metatype || !this.toValidate(metadata)) {
|
|
48
49
|
return value;
|
|
49
50
|
}
|
|
50
|
-
const entity = classTransformer.plainToClass(metatype, this.toEmptyIfNil(value));
|
|
51
|
+
const entity = classTransformer.plainToClass(metatype, this.toEmptyIfNil(value), this.transformOptions);
|
|
51
52
|
const errors = await classValidator.validate(entity, this.validatorOptions);
|
|
52
53
|
if (errors.length > 0) {
|
|
53
54
|
throw this.exceptionFactory(errors);
|
|
@@ -55,7 +56,7 @@ let ValidationPipe = class ValidationPipe {
|
|
|
55
56
|
return this.isTransformEnabled
|
|
56
57
|
? entity
|
|
57
58
|
: Object.keys(this.validatorOptions).length > 0
|
|
58
|
-
? classTransformer.classToPlain(entity)
|
|
59
|
+
? classTransformer.classToPlain(entity, this.transformOptions)
|
|
59
60
|
: value;
|
|
60
61
|
}
|
|
61
62
|
toValidate(metadata) {
|