@nestjs/common 7.6.11 → 7.6.15
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 +5 -4
- package/cache/interceptors/cache.interceptor.js +3 -2
- package/decorators/http/route-params.decorator.d.ts +55 -4
- package/decorators/http/route-params.decorator.js +10 -4
- package/interfaces/external/class-transform-options.interface.d.ts +7 -0
- package/interfaces/external/cors-options.interface.d.ts +4 -2
- package/interfaces/http/http-server.interface.d.ts +1 -1
- package/package.json +1 -1
- package/pipes/default-value.pipe.d.ts +1 -1
- package/pipes/default-value.pipe.js +2 -2
- package/pipes/parse-array.pipe.d.ts +1 -2
- package/pipes/parse-array.pipe.js +6 -4
- package/pipes/parse-bool.pipe.d.ts +1 -2
- package/pipes/parse-bool.pipe.js +6 -4
- package/pipes/parse-int.pipe.d.ts +1 -2
- package/pipes/parse-int.pipe.js +6 -4
- package/pipes/parse-uuid.pipe.d.ts +1 -2
- package/pipes/parse-uuid.pipe.js +6 -5
- package/pipes/validation.pipe.d.ts +2 -2
package/Readme.md
CHANGED
|
@@ -37,6 +37,7 @@ Nest is a framework for building efficient, scalable <a href="http://nodejs.org"
|
|
|
37
37
|
|
|
38
38
|
* To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https://docs.nestjs.com). :books:
|
|
39
39
|
* 要查看中文 [指南](readme_zh.md), 请访问 [docs.nestjs.cn](https://docs.nestjs.cn). :books:
|
|
40
|
+
* [가이드](readme_kr.md)를 확인하려면, [docs.nestjs.com](https://docs.nestjs.com)를 방문하세요.:books:
|
|
40
41
|
|
|
41
42
|
## Questions
|
|
42
43
|
|
|
@@ -95,11 +96,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
95
96
|
<td align="center" valign="middle">
|
|
96
97
|
<a href="https://genuinebee.com/" target="_blank"><img src="https://nestjs.com/img/genuinebee.svg" width="97" valign="middle" /></a> </td>
|
|
97
98
|
<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
99
|
<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
|
-
|
|
100
|
+
<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></tr><tr>
|
|
101
|
+
<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>
|
|
102
|
+
<td align="center" valign="middle"><a href="https://houseofangular.io/" target="_blank"><img src="https://nestjs.com/img/house-of-angular.png" width="100" valign="middle" /></a></td>
|
|
103
|
+
<td align="center" valign="middle"><a href="https://rocketech.it/cases/?utm_source=google&utm_medium=badge&utm_campaign=nestjs" target="_blank"><img src="https://nestjs.com/img/rocketech-logo.svg" width="110" valign="middle" /></a></td>
|
|
103
104
|
</tr></table>
|
|
104
105
|
|
|
105
106
|
## Backers
|
|
@@ -15,8 +15,9 @@ let CacheInterceptor = class CacheInterceptor {
|
|
|
15
15
|
this.reflector = reflector;
|
|
16
16
|
}
|
|
17
17
|
async intercept(context, next) {
|
|
18
|
+
var _a;
|
|
18
19
|
const key = this.trackBy(context);
|
|
19
|
-
const ttlValueOrFactory = this.reflector.get(cache_constants_1.CACHE_TTL_METADATA, context.getHandler())
|
|
20
|
+
const ttlValueOrFactory = (_a = this.reflector.get(cache_constants_1.CACHE_TTL_METADATA, context.getHandler())) !== null && _a !== void 0 ? _a : null;
|
|
20
21
|
if (!key) {
|
|
21
22
|
return next.handle();
|
|
22
23
|
}
|
|
@@ -33,7 +34,7 @@ let CacheInterceptor = class CacheInterceptor {
|
|
|
33
34
|
this.cacheManager.set(...args);
|
|
34
35
|
}));
|
|
35
36
|
}
|
|
36
|
-
catch (
|
|
37
|
+
catch (_b) {
|
|
37
38
|
return next.handle();
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -79,7 +79,7 @@ export declare const Session: () => ParameterDecorator;
|
|
|
79
79
|
* Route handler parameter decorator. Extracts the `file` object
|
|
80
80
|
* and populates the decorated parameter with the value of `file`.
|
|
81
81
|
* Used in conjunction with
|
|
82
|
-
* [multer middleware](https://github.com/expressjs/multer).
|
|
82
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
83
83
|
*
|
|
84
84
|
* For example:
|
|
85
85
|
* ```typescript
|
|
@@ -91,12 +91,63 @@ export declare const Session: () => ParameterDecorator;
|
|
|
91
91
|
*
|
|
92
92
|
* @publicApi
|
|
93
93
|
*/
|
|
94
|
-
export declare
|
|
94
|
+
export declare function UploadedFile(): ParameterDecorator;
|
|
95
|
+
/**
|
|
96
|
+
* Route handler parameter decorator. Extracts the `file` object
|
|
97
|
+
* and populates the decorated parameter with the value of `file`.
|
|
98
|
+
* Used in conjunction with
|
|
99
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
100
|
+
*
|
|
101
|
+
* For example:
|
|
102
|
+
* ```typescript
|
|
103
|
+
* uploadFile(@UploadedFile() file) {
|
|
104
|
+
* console.log(file);
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
108
|
+
*
|
|
109
|
+
* @publicApi
|
|
110
|
+
*/
|
|
111
|
+
export declare function UploadedFile(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
112
|
+
/**
|
|
113
|
+
* Route handler parameter decorator. Extracts the `file` object
|
|
114
|
+
* and populates the decorated parameter with the value of `file`.
|
|
115
|
+
* Used in conjunction with
|
|
116
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
117
|
+
*
|
|
118
|
+
* For example:
|
|
119
|
+
* ```typescript
|
|
120
|
+
* uploadFile(@UploadedFile() file) {
|
|
121
|
+
* console.log(file);
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
125
|
+
*
|
|
126
|
+
* @publicApi
|
|
127
|
+
*/
|
|
128
|
+
export declare function UploadedFile(fileKey?: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
129
|
+
/**
|
|
130
|
+
* Route handler parameter decorator. Extracts the `files` object
|
|
131
|
+
* and populates the decorated parameter with the value of `files`.
|
|
132
|
+
* Used in conjunction with
|
|
133
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
134
|
+
*
|
|
135
|
+
* For example:
|
|
136
|
+
* ```typescript
|
|
137
|
+
* uploadFile(@UploadedFiles() files) {
|
|
138
|
+
* console.log(files);
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
142
|
+
*
|
|
143
|
+
* @publicApi
|
|
144
|
+
*/
|
|
145
|
+
export declare function UploadedFiles(): ParameterDecorator;
|
|
95
146
|
/**
|
|
96
147
|
* Route handler parameter decorator. Extracts the `files` object
|
|
97
148
|
* and populates the decorated parameter with the value of `files`.
|
|
98
149
|
* Used in conjunction with
|
|
99
|
-
* [multer middleware](https://github.com/expressjs/multer).
|
|
150
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
100
151
|
*
|
|
101
152
|
* For example:
|
|
102
153
|
* ```typescript
|
|
@@ -108,7 +159,7 @@ export declare const UploadedFile: (fileKey?: string) => ParameterDecorator;
|
|
|
108
159
|
*
|
|
109
160
|
* @publicApi
|
|
110
161
|
*/
|
|
111
|
-
export declare
|
|
162
|
+
export declare function UploadedFiles(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
112
163
|
/**
|
|
113
164
|
* Route handler parameter decorator. Extracts the `headers`
|
|
114
165
|
* property from the `req` object and populates the decorated
|
|
@@ -85,7 +85,7 @@ exports.Session = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamty
|
|
|
85
85
|
* Route handler parameter decorator. Extracts the `file` object
|
|
86
86
|
* and populates the decorated parameter with the value of `file`.
|
|
87
87
|
* Used in conjunction with
|
|
88
|
-
* [multer middleware](https://github.com/expressjs/multer).
|
|
88
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
89
89
|
*
|
|
90
90
|
* For example:
|
|
91
91
|
* ```typescript
|
|
@@ -97,12 +97,15 @@ exports.Session = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamty
|
|
|
97
97
|
*
|
|
98
98
|
* @publicApi
|
|
99
99
|
*/
|
|
100
|
-
|
|
100
|
+
function UploadedFile(fileKey, ...pipes) {
|
|
101
|
+
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.FILE)(fileKey, ...pipes);
|
|
102
|
+
}
|
|
103
|
+
exports.UploadedFile = UploadedFile;
|
|
101
104
|
/**
|
|
102
105
|
* Route handler parameter decorator. Extracts the `files` object
|
|
103
106
|
* and populates the decorated parameter with the value of `files`.
|
|
104
107
|
* Used in conjunction with
|
|
105
|
-
* [multer middleware](https://github.com/expressjs/multer).
|
|
108
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
106
109
|
*
|
|
107
110
|
* For example:
|
|
108
111
|
* ```typescript
|
|
@@ -114,7 +117,10 @@ exports.UploadedFile = createRouteParamDecorator(route_paramtypes_enum_1.RoutePa
|
|
|
114
117
|
*
|
|
115
118
|
* @publicApi
|
|
116
119
|
*/
|
|
117
|
-
|
|
120
|
+
function UploadedFiles(...pipes) {
|
|
121
|
+
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.FILES)(undefined, ...pipes);
|
|
122
|
+
}
|
|
123
|
+
exports.UploadedFiles = UploadedFiles;
|
|
118
124
|
/**
|
|
119
125
|
* Route handler parameter decorator. Extracts the `headers`
|
|
120
126
|
* property from the `req` object and populates the decorated
|
|
@@ -55,4 +55,11 @@ export interface ClassTransformOptions {
|
|
|
55
55
|
* This is useful when you convert a plain object to a class and have an optional field with a default value.
|
|
56
56
|
*/
|
|
57
57
|
exposeDefaultValues?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* When set to true, fields with `undefined` as value will be included in class to plain transformation. Otherwise
|
|
60
|
+
* those fields will be omitted from the result.
|
|
61
|
+
*
|
|
62
|
+
* DEFAULT: `true`
|
|
63
|
+
*/
|
|
64
|
+
exposeUnsetFields?: boolean;
|
|
58
65
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
declare type StaticOrigin = boolean | string | RegExp | (string | RegExp)[];
|
|
1
2
|
/**
|
|
2
3
|
* Set origin to a function implementing some custom logic. The function takes the
|
|
3
4
|
* request origin as the first parameter and a callback (which expects the signature
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
*
|
|
8
9
|
* @publicApi
|
|
9
10
|
*/
|
|
10
|
-
export declare type CustomOrigin = (requestOrigin: string, callback: (err: Error | null,
|
|
11
|
+
export declare type CustomOrigin = (requestOrigin: string, callback: (err: Error | null, origin?: StaticOrigin) => void) => void;
|
|
11
12
|
/**
|
|
12
13
|
* Interface describing CORS options that can be set.
|
|
13
14
|
*
|
|
@@ -18,7 +19,7 @@ export interface CorsOptions {
|
|
|
18
19
|
/**
|
|
19
20
|
* Configures the `Access-Control-Allow-Origins` CORS header. See [here for more detail.](https://github.com/expressjs/cors#configuration-options)
|
|
20
21
|
*/
|
|
21
|
-
origin?:
|
|
22
|
+
origin?: StaticOrigin | CustomOrigin;
|
|
22
23
|
/**
|
|
23
24
|
* Configures the Access-Control-Allow-Methods CORS header.
|
|
24
25
|
*/
|
|
@@ -54,3 +55,4 @@ export interface CorsOptionsCallback {
|
|
|
54
55
|
export interface CorsOptionsDelegate<T> {
|
|
55
56
|
(req: T, cb: CorsOptionsCallback): void;
|
|
56
57
|
}
|
|
58
|
+
export {};
|
|
@@ -35,7 +35,7 @@ export interface HttpServer<TRequest = any, TResponse = any> {
|
|
|
35
35
|
createMiddlewareFactory(method: RequestMethod): ((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>;
|
|
36
36
|
getRequestHostname?(request: TRequest): string;
|
|
37
37
|
getRequestMethod?(request: TRequest): string;
|
|
38
|
-
getRequestUrl?(request:
|
|
38
|
+
getRequestUrl?(request: TRequest): string;
|
|
39
39
|
getInstance(): any;
|
|
40
40
|
registerParserMiddleware(): any;
|
|
41
41
|
enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>): any;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultValuePipe = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
|
|
6
6
|
const shared_utils_1 = require("../utils/shared.utils");
|
|
7
7
|
/**
|
|
8
8
|
* Defines the built-in DefaultValue Pipe
|
|
@@ -24,7 +24,7 @@ let DefaultValuePipe = class DefaultValuePipe {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
DefaultValuePipe = tslib_1.__decorate([
|
|
27
|
-
|
|
27
|
+
injectable_decorator_1.Injectable(),
|
|
28
28
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
29
29
|
], DefaultValuePipe);
|
|
30
30
|
exports.DefaultValuePipe = DefaultValuePipe;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ArgumentMetadata } from '../index';
|
|
2
1
|
import { Type } from '../interfaces';
|
|
3
|
-
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
2
|
+
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
4
3
|
import { ValidationPipe, ValidationPipeOptions } from './validation.pipe';
|
|
5
4
|
export interface ParseArrayOptions extends Omit<ValidationPipeOptions, 'transform' | 'validateCustomDecorators' | 'exceptionFactory'> {
|
|
6
5
|
items?: Type<unknown>;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParseArrayPipe = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
|
|
6
|
+
const optional_decorator_1 = require("../decorators/core/optional.decorator");
|
|
7
|
+
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
6
8
|
const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
7
9
|
const shared_utils_1 = require("../utils/shared.utils");
|
|
8
10
|
const validation_pipe_1 = require("./validation.pipe");
|
|
@@ -19,7 +21,7 @@ let ParseArrayPipe = class ParseArrayPipe {
|
|
|
19
21
|
constructor(options = {}) {
|
|
20
22
|
this.options = options;
|
|
21
23
|
this.validationPipe = new validation_pipe_1.ValidationPipe(Object.assign({ transform: true, validateCustomDecorators: true }, options));
|
|
22
|
-
const { exceptionFactory, errorHttpStatusCode =
|
|
24
|
+
const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST, } = options;
|
|
23
25
|
this.exceptionFactory =
|
|
24
26
|
exceptionFactory ||
|
|
25
27
|
(error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
|
|
@@ -104,8 +106,8 @@ let ParseArrayPipe = class ParseArrayPipe {
|
|
|
104
106
|
}
|
|
105
107
|
};
|
|
106
108
|
ParseArrayPipe = tslib_1.__decorate([
|
|
107
|
-
|
|
108
|
-
tslib_1.__param(0,
|
|
109
|
+
injectable_decorator_1.Injectable(),
|
|
110
|
+
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
109
111
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
110
112
|
], ParseArrayPipe);
|
|
111
113
|
exports.ParseArrayPipe = ParseArrayPipe;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ArgumentMetadata } from '../
|
|
2
|
-
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
1
|
+
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
3
2
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
4
3
|
export interface ParseBoolPipeOptions {
|
|
5
4
|
errorHttpStatusCode?: ErrorHttpStatusCode;
|
package/pipes/parse-bool.pipe.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParseBoolPipe = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
|
|
6
|
+
const optional_decorator_1 = require("../decorators/core/optional.decorator");
|
|
7
|
+
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
6
8
|
const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
7
9
|
/**
|
|
8
10
|
* Defines the built-in ParseBool Pipe
|
|
@@ -14,7 +16,7 @@ const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
|
14
16
|
let ParseBoolPipe = class ParseBoolPipe {
|
|
15
17
|
constructor(options) {
|
|
16
18
|
options = options || {};
|
|
17
|
-
const { exceptionFactory, errorHttpStatusCode =
|
|
19
|
+
const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST, } = options;
|
|
18
20
|
this.exceptionFactory =
|
|
19
21
|
exceptionFactory ||
|
|
20
22
|
(error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
|
|
@@ -37,8 +39,8 @@ let ParseBoolPipe = class ParseBoolPipe {
|
|
|
37
39
|
}
|
|
38
40
|
};
|
|
39
41
|
ParseBoolPipe = tslib_1.__decorate([
|
|
40
|
-
|
|
41
|
-
tslib_1.__param(0,
|
|
42
|
+
injectable_decorator_1.Injectable(),
|
|
43
|
+
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
42
44
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
43
45
|
], ParseBoolPipe);
|
|
44
46
|
exports.ParseBoolPipe = ParseBoolPipe;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ArgumentMetadata } from '../
|
|
2
|
-
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
1
|
+
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
3
2
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
4
3
|
export interface ParseIntPipeOptions {
|
|
5
4
|
errorHttpStatusCode?: ErrorHttpStatusCode;
|
package/pipes/parse-int.pipe.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParseIntPipe = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
|
|
6
|
+
const optional_decorator_1 = require("../decorators/core/optional.decorator");
|
|
7
|
+
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
6
8
|
const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
7
9
|
/**
|
|
8
10
|
* Defines the built-in ParseInt Pipe
|
|
@@ -14,7 +16,7 @@ const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
|
14
16
|
let ParseIntPipe = class ParseIntPipe {
|
|
15
17
|
constructor(options) {
|
|
16
18
|
options = options || {};
|
|
17
|
-
const { exceptionFactory, errorHttpStatusCode =
|
|
19
|
+
const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST, } = options;
|
|
18
20
|
this.exceptionFactory =
|
|
19
21
|
exceptionFactory ||
|
|
20
22
|
(error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
|
|
@@ -37,8 +39,8 @@ let ParseIntPipe = class ParseIntPipe {
|
|
|
37
39
|
}
|
|
38
40
|
};
|
|
39
41
|
ParseIntPipe = tslib_1.__decorate([
|
|
40
|
-
|
|
41
|
-
tslib_1.__param(0,
|
|
42
|
+
injectable_decorator_1.Injectable(),
|
|
43
|
+
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
42
44
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
43
45
|
], ParseIntPipe);
|
|
44
46
|
exports.ParseIntPipe = ParseIntPipe;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ArgumentMetadata } from '../
|
|
2
|
-
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
1
|
+
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
3
2
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
4
3
|
export interface ParseUUIDPipeOptions {
|
|
5
4
|
version?: '3' | '4' | '5';
|
package/pipes/parse-uuid.pipe.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParseUUIDPipe = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
|
|
6
|
+
const optional_decorator_1 = require("../decorators/core/optional.decorator");
|
|
7
|
+
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
7
8
|
const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
8
9
|
const is_uuid_1 = require("../utils/is-uuid");
|
|
9
10
|
let ParseUUIDPipe = class ParseUUIDPipe {
|
|
10
11
|
constructor(options) {
|
|
11
12
|
options = options || {};
|
|
12
|
-
const { exceptionFactory, errorHttpStatusCode =
|
|
13
|
+
const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST, version, } = options;
|
|
13
14
|
this.version = version;
|
|
14
15
|
this.exceptionFactory =
|
|
15
16
|
exceptionFactory ||
|
|
@@ -23,8 +24,8 @@ let ParseUUIDPipe = class ParseUUIDPipe {
|
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
ParseUUIDPipe = tslib_1.__decorate([
|
|
26
|
-
|
|
27
|
-
tslib_1.__param(0,
|
|
27
|
+
injectable_decorator_1.Injectable(),
|
|
28
|
+
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
28
29
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
29
30
|
], ParseUUIDPipe);
|
|
30
31
|
exports.ParseUUIDPipe = ParseUUIDPipe;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ArgumentMetadata, ValidationError } from '../index';
|
|
2
1
|
import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface';
|
|
2
|
+
import { ValidationError } from '../interfaces/external/validation-error.interface';
|
|
3
3
|
import { ValidatorOptions } from '../interfaces/external/validator-options.interface';
|
|
4
|
-
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
4
|
+
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
5
5
|
import { Type } from '../interfaces/type.interface';
|
|
6
6
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
7
7
|
export interface ValidationPipeOptions extends ValidatorOptions {
|