@nestjs/common 6.11.7 → 6.11.11
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 +1 -1
- package/decorators/core/injectable.decorator.js +2 -2
- package/decorators/http/create-route-param-metadata.decorator.js +2 -2
- package/exceptions/http-version-not-supported.exception.d.ts +36 -0
- package/exceptions/http-version-not-supported.exception.js +42 -0
- package/http/http.service.d.ts +1 -1
- package/interfaces/microservices/microservice-configuration.interface.d.ts +12 -0
- package/package.json +3 -3
- package/pipes/parse-int.pipe.d.ts +5 -0
- package/pipes/parse-int.pipe.js +10 -2
- package/utils/random-string-generator.util.js +2 -2
package/Readme.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
11
11
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
12
|
-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/
|
|
12
|
+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
|
13
13
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
|
14
14
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
|
15
15
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const uuid_1 = require("uuid");
|
|
4
4
|
const constants_1 = require("../../constants");
|
|
5
5
|
/**
|
|
6
6
|
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers).
|
|
@@ -38,7 +38,7 @@ function Injectable(options) {
|
|
|
38
38
|
exports.Injectable = Injectable;
|
|
39
39
|
function mixin(mixinClass) {
|
|
40
40
|
Object.defineProperty(mixinClass, 'name', {
|
|
41
|
-
value:
|
|
41
|
+
value: uuid_1.v4(),
|
|
42
42
|
});
|
|
43
43
|
Injectable()(mixinClass);
|
|
44
44
|
return mixinClass;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const uuid_1 = require("uuid");
|
|
4
4
|
const constants_1 = require("../../constants");
|
|
5
5
|
const shared_utils_1 = require("../../utils/shared.utils");
|
|
6
6
|
const assignCustomMetadata = (args, paramtype, index, factory, data, ...pipes) => (Object.assign(Object.assign({}, args), { [`${paramtype}${constants_1.CUSTOM_ROUTE_AGRS_METADATA}:${index}`]: {
|
|
@@ -15,7 +15,7 @@ const assignCustomMetadata = (args, paramtype, index, factory, data, ...pipes) =
|
|
|
15
15
|
* @param factory
|
|
16
16
|
*/
|
|
17
17
|
function createParamDecorator(factory, enhancers = []) {
|
|
18
|
-
const paramtype =
|
|
18
|
+
const paramtype = uuid_1.v4();
|
|
19
19
|
return (data, ...pipes) => (target, key, index) => {
|
|
20
20
|
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
|
|
21
21
|
const isPipe = (pipe) => pipe &&
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HttpException } from './http.exception';
|
|
2
|
+
/**
|
|
3
|
+
* Defines an HTTP exception for *Http Version Not Supported* type errors.
|
|
4
|
+
*
|
|
5
|
+
* @see [Base Exceptions](https://docs.nestjs.com/exception-filters#base-exceptions)
|
|
6
|
+
*
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
export declare class HttpVersionNotSupportedException extends HttpException {
|
|
10
|
+
/**
|
|
11
|
+
* Instantiate a `HttpVersionNotSupportedException` Exception.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* `throw new HttpVersionNotSupportedException()`
|
|
15
|
+
*
|
|
16
|
+
* @usageNotes
|
|
17
|
+
* The constructor arguments define the HTTP response.
|
|
18
|
+
* - The `message` argument defines the JSON response body.
|
|
19
|
+
* - The `error` argument defines the HTTP Status Code.
|
|
20
|
+
*
|
|
21
|
+
* By default, the JSON response body contains two properties:
|
|
22
|
+
* - `statusCode`: defaults to the Http Status Code provided in the `error` argument
|
|
23
|
+
* - `message`: the string `'HTTP Version Not Supported'` by default; override this by supplying
|
|
24
|
+
* a string in the `message` parameter.
|
|
25
|
+
*
|
|
26
|
+
* To override the entire JSON response body, pass an object. Nest will serialize
|
|
27
|
+
* the object and return it as the JSON response body.
|
|
28
|
+
*
|
|
29
|
+
* The `error` argument is required, and should be a valid HTTP status code.
|
|
30
|
+
* Best practice is to use the `HttpStatus` enum imported from `nestjs/common`.
|
|
31
|
+
*
|
|
32
|
+
* @param message string or object describing the error condition.
|
|
33
|
+
* @param error HTTP response status code
|
|
34
|
+
*/
|
|
35
|
+
constructor(message?: string | object | any, error?: string);
|
|
36
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const http_exception_1 = require("./http.exception");
|
|
4
|
+
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
+
/**
|
|
6
|
+
* Defines an HTTP exception for *Http Version Not Supported* type errors.
|
|
7
|
+
*
|
|
8
|
+
* @see [Base Exceptions](https://docs.nestjs.com/exception-filters#base-exceptions)
|
|
9
|
+
*
|
|
10
|
+
* @publicApi
|
|
11
|
+
*/
|
|
12
|
+
class HttpVersionNotSupportedException extends http_exception_1.HttpException {
|
|
13
|
+
/**
|
|
14
|
+
* Instantiate a `HttpVersionNotSupportedException` Exception.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* `throw new HttpVersionNotSupportedException()`
|
|
18
|
+
*
|
|
19
|
+
* @usageNotes
|
|
20
|
+
* The constructor arguments define the HTTP response.
|
|
21
|
+
* - The `message` argument defines the JSON response body.
|
|
22
|
+
* - The `error` argument defines the HTTP Status Code.
|
|
23
|
+
*
|
|
24
|
+
* By default, the JSON response body contains two properties:
|
|
25
|
+
* - `statusCode`: defaults to the Http Status Code provided in the `error` argument
|
|
26
|
+
* - `message`: the string `'HTTP Version Not Supported'` by default; override this by supplying
|
|
27
|
+
* a string in the `message` parameter.
|
|
28
|
+
*
|
|
29
|
+
* To override the entire JSON response body, pass an object. Nest will serialize
|
|
30
|
+
* the object and return it as the JSON response body.
|
|
31
|
+
*
|
|
32
|
+
* The `error` argument is required, and should be a valid HTTP status code.
|
|
33
|
+
* Best practice is to use the `HttpStatus` enum imported from `nestjs/common`.
|
|
34
|
+
*
|
|
35
|
+
* @param message string or object describing the error condition.
|
|
36
|
+
* @param error HTTP response status code
|
|
37
|
+
*/
|
|
38
|
+
constructor(message, error = 'HTTP Version Not Supported') {
|
|
39
|
+
super(http_exception_1.HttpException.createBody(message, error, http_status_enum_1.HttpStatus.HTTP_VERSION_NOT_SUPPORTED), http_status_enum_1.HttpStatus.HTTP_VERSION_NOT_SUPPORTED);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.HttpVersionNotSupportedException = HttpVersionNotSupportedException;
|
package/http/http.service.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ export declare class HttpService {
|
|
|
10
10
|
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
11
11
|
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
12
12
|
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
13
|
-
|
|
13
|
+
get axiosRef(): AxiosInstance;
|
|
14
14
|
private makeObservable;
|
|
15
15
|
}
|
|
@@ -15,6 +15,15 @@ export interface GrpcOptions {
|
|
|
15
15
|
url?: string;
|
|
16
16
|
maxSendMessageLength?: number;
|
|
17
17
|
maxReceiveMessageLength?: number;
|
|
18
|
+
keepalive?: {
|
|
19
|
+
keepaliveTimeMs?: number;
|
|
20
|
+
keepaliveTimeoutMs?: number;
|
|
21
|
+
keepalivePermitWithoutCalls?: number;
|
|
22
|
+
http2MaxPingsWithoutData?: number;
|
|
23
|
+
http2MinTimeBetweenPingsMs?: number;
|
|
24
|
+
http2MinPingIntervalWithoutDataMs?: number;
|
|
25
|
+
http2MaxPingStrikes?: number;
|
|
26
|
+
};
|
|
18
27
|
credentials?: any;
|
|
19
28
|
protoPath: string | string[];
|
|
20
29
|
package: string | string[];
|
|
@@ -104,6 +113,9 @@ export interface KafkaOptions {
|
|
|
104
113
|
eachBatchAutoResolve?: boolean;
|
|
105
114
|
partitionsConsumedConcurrently?: number;
|
|
106
115
|
};
|
|
116
|
+
subscribe?: {
|
|
117
|
+
fromBeginning?: boolean;
|
|
118
|
+
};
|
|
107
119
|
producer?: ProducerConfig;
|
|
108
120
|
send?: {
|
|
109
121
|
acks?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/common",
|
|
3
|
-
"version": "6.11.
|
|
3
|
+
"version": "6.11.11",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"homepage": "https://nestjs.com",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"axios": "0.19.2",
|
|
21
21
|
"cli-color": "2.0.0",
|
|
22
|
-
"tslib": "1.
|
|
23
|
-
"uuid": "
|
|
22
|
+
"tslib": "1.11.1",
|
|
23
|
+
"uuid": "7.0.1"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"reflect-metadata": "^0.1.12",
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
2
2
|
import { ArgumentMetadata } from '../index';
|
|
3
|
+
export interface ParseIntPipeOptions {
|
|
4
|
+
exceptionFactory?: (error: string) => any;
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* Defines the built-in ParseInt Pipe
|
|
5
8
|
*
|
|
@@ -8,6 +11,8 @@ import { ArgumentMetadata } from '../index';
|
|
|
8
11
|
* @publicApi
|
|
9
12
|
*/
|
|
10
13
|
export declare class ParseIntPipe implements PipeTransform<string> {
|
|
14
|
+
protected exceptionFactory: (error: string) => any;
|
|
15
|
+
constructor(options?: ParseIntPipeOptions);
|
|
11
16
|
/**
|
|
12
17
|
* Method that accesses and performs optional transformation on argument for
|
|
13
18
|
* in-flight requests.
|
package/pipes/parse-int.pipe.js
CHANGED
|
@@ -11,6 +11,12 @@ const index_1 = require("../index");
|
|
|
11
11
|
* @publicApi
|
|
12
12
|
*/
|
|
13
13
|
let ParseIntPipe = class ParseIntPipe {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
options = options || {};
|
|
16
|
+
const { exceptionFactory } = options;
|
|
17
|
+
this.exceptionFactory =
|
|
18
|
+
exceptionFactory || (error => new bad_request_exception_1.BadRequestException(error));
|
|
19
|
+
}
|
|
14
20
|
/**
|
|
15
21
|
* Method that accesses and performs optional transformation on argument for
|
|
16
22
|
* in-flight requests.
|
|
@@ -23,12 +29,14 @@ let ParseIntPipe = class ParseIntPipe {
|
|
|
23
29
|
!isNaN(parseFloat(value)) &&
|
|
24
30
|
isFinite(value);
|
|
25
31
|
if (!isNumeric) {
|
|
26
|
-
throw
|
|
32
|
+
throw this.exceptionFactory('Validation failed (numeric string is expected)');
|
|
27
33
|
}
|
|
28
34
|
return parseInt(value, 10);
|
|
29
35
|
}
|
|
30
36
|
};
|
|
31
37
|
ParseIntPipe = tslib_1.__decorate([
|
|
32
|
-
index_1.Injectable()
|
|
38
|
+
index_1.Injectable(),
|
|
39
|
+
tslib_1.__param(0, index_1.Optional()),
|
|
40
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
33
41
|
], ParseIntPipe);
|
|
34
42
|
exports.ParseIntPipe = ParseIntPipe;
|