@nestjs/platform-express 8.3.1 → 8.4.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 +1 -1
- package/adapters/express-adapter.js +43 -9
- package/multer/interceptors/any-files.interceptor.js +4 -4
- package/multer/interceptors/file-fields.interceptor.js +4 -4
- package/multer/interceptors/file.interceptor.js +4 -4
- package/multer/interceptors/files.interceptor.js +4 -4
- package/multer/multer.module.js +3 -3
- package/package.json +5 -5
- package/CHANGELOG.md +0 -12
package/Readme.md
CHANGED
|
@@ -54,7 +54,7 @@ With official support, you can get expert help straight from Nest core team. We
|
|
|
54
54
|
|
|
55
55
|
## Support
|
|
56
56
|
|
|
57
|
-
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support
|
|
57
|
+
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support from the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
|
58
58
|
|
|
59
59
|
#### Principal Sponsors
|
|
60
60
|
<table style="text-align:center;"><tr>
|
|
@@ -20,20 +20,26 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
20
20
|
if (statusCode) {
|
|
21
21
|
response.status(statusCode);
|
|
22
22
|
}
|
|
23
|
-
if (shared_utils_1.isNil(body)) {
|
|
23
|
+
if ((0, shared_utils_1.isNil)(body)) {
|
|
24
24
|
return response.send();
|
|
25
25
|
}
|
|
26
26
|
if (body instanceof common_1.StreamableFile) {
|
|
27
27
|
const streamHeaders = body.getHeaders();
|
|
28
|
-
if (response.getHeader('Content-Type') === undefined
|
|
28
|
+
if (response.getHeader('Content-Type') === undefined &&
|
|
29
|
+
streamHeaders.type !== undefined) {
|
|
29
30
|
response.setHeader('Content-Type', streamHeaders.type);
|
|
30
31
|
}
|
|
31
|
-
if (response.getHeader('Content-Disposition') === undefined
|
|
32
|
+
if (response.getHeader('Content-Disposition') === undefined &&
|
|
33
|
+
streamHeaders.disposition !== undefined) {
|
|
32
34
|
response.setHeader('Content-Disposition', streamHeaders.disposition);
|
|
33
35
|
}
|
|
36
|
+
if (response.getHeader('Content-Length') === undefined &&
|
|
37
|
+
streamHeaders.length !== undefined) {
|
|
38
|
+
response.setHeader('Content-Length', streamHeaders.length);
|
|
39
|
+
}
|
|
34
40
|
return body.getStream().pipe(response);
|
|
35
41
|
}
|
|
36
|
-
return shared_utils_1.isObject(body) ? response.json(body) : response.send(String(body));
|
|
42
|
+
return (0, shared_utils_1.isObject)(body) ? response.json(body) : response.send(String(body));
|
|
37
43
|
}
|
|
38
44
|
status(response, statusCode) {
|
|
39
45
|
return response.status(statusCode);
|
|
@@ -113,8 +119,8 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
113
119
|
}
|
|
114
120
|
registerParserMiddleware() {
|
|
115
121
|
const parserMiddleware = {
|
|
116
|
-
jsonParser: body_parser_1.json(),
|
|
117
|
-
urlencodedParser: body_parser_1.urlencoded({ extended: true }),
|
|
122
|
+
jsonParser: (0, body_parser_1.json)(),
|
|
123
|
+
urlencodedParser: (0, body_parser_1.urlencoded)({ extended: true }),
|
|
118
124
|
};
|
|
119
125
|
Object.keys(parserMiddleware)
|
|
120
126
|
.filter(parser => !this.isMiddlewareApplied(parser))
|
|
@@ -137,6 +143,34 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
137
143
|
if (versioningOptions.type === common_1.VersioningType.URI) {
|
|
138
144
|
return handler(req, res, next);
|
|
139
145
|
}
|
|
146
|
+
// Custom Extractor Versioning Handler
|
|
147
|
+
if (versioningOptions.type === common_1.VersioningType.CUSTOM) {
|
|
148
|
+
const extractedVersion = versioningOptions.extractor(req);
|
|
149
|
+
if (Array.isArray(version)) {
|
|
150
|
+
if (Array.isArray(extractedVersion) &&
|
|
151
|
+
version.filter(v => extractedVersion.includes(v)).length) {
|
|
152
|
+
return handler(req, res, next);
|
|
153
|
+
}
|
|
154
|
+
else if ((0, shared_utils_1.isString)(extractedVersion) &&
|
|
155
|
+
version.includes(extractedVersion)) {
|
|
156
|
+
return handler(req, res, next);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else if ((0, shared_utils_1.isString)(version)) {
|
|
160
|
+
// Known bug here - if there are multiple versions supported across separate
|
|
161
|
+
// handlers/controllers, we can't select the highest matching handler.
|
|
162
|
+
// Since this code is evaluated per-handler, then we can't see if the highest
|
|
163
|
+
// specified version exists in a different handler.
|
|
164
|
+
if (Array.isArray(extractedVersion) &&
|
|
165
|
+
extractedVersion.includes(version)) {
|
|
166
|
+
return handler(req, res, next);
|
|
167
|
+
}
|
|
168
|
+
else if ((0, shared_utils_1.isString)(extractedVersion) &&
|
|
169
|
+
version === extractedVersion) {
|
|
170
|
+
return handler(req, res, next);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
140
174
|
// Media Type (Accept Header) Versioning Handler
|
|
141
175
|
if (versioningOptions.type === common_1.VersioningType.MEDIA_TYPE) {
|
|
142
176
|
const MEDIA_TYPE_HEADER = 'Accept';
|
|
@@ -152,7 +186,7 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
152
186
|
return handler(req, res, next);
|
|
153
187
|
}
|
|
154
188
|
}
|
|
155
|
-
else if (shared_utils_1.isString(version)) {
|
|
189
|
+
else if ((0, shared_utils_1.isString)(version)) {
|
|
156
190
|
if (version === headerVersion) {
|
|
157
191
|
return handler(req, res, next);
|
|
158
192
|
}
|
|
@@ -169,7 +203,7 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
169
203
|
return handler(req, res, next);
|
|
170
204
|
}
|
|
171
205
|
}
|
|
172
|
-
else if (shared_utils_1.isString(version)) {
|
|
206
|
+
else if ((0, shared_utils_1.isString)(version)) {
|
|
173
207
|
if (version === customHeaderVersionParameter) {
|
|
174
208
|
return handler(req, res, next);
|
|
175
209
|
}
|
|
@@ -186,7 +220,7 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
186
220
|
const app = this.getInstance();
|
|
187
221
|
return (!!app._router &&
|
|
188
222
|
!!app._router.stack &&
|
|
189
|
-
shared_utils_1.isFunction(app._router.stack.filter) &&
|
|
223
|
+
(0, shared_utils_1.isFunction)(app._router.stack.filter) &&
|
|
190
224
|
app._router.stack.some((layer) => layer && layer.handle && layer.handle.name === name));
|
|
191
225
|
}
|
|
192
226
|
}
|
|
@@ -15,7 +15,7 @@ function AnyFilesInterceptor(localOptions) {
|
|
|
15
15
|
const ctx = context.switchToHttp();
|
|
16
16
|
await new Promise((resolve, reject) => this.multer.any()(ctx.getRequest(), ctx.getResponse(), (err) => {
|
|
17
17
|
if (err) {
|
|
18
|
-
const error = multer_utils_1.transformException(err);
|
|
18
|
+
const error = (0, multer_utils_1.transformException)(err);
|
|
19
19
|
return reject(error);
|
|
20
20
|
}
|
|
21
21
|
resolve();
|
|
@@ -24,11 +24,11 @@ function AnyFilesInterceptor(localOptions) {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
MixinInterceptor = tslib_1.__decorate([
|
|
27
|
-
tslib_1.__param(0, common_1.Optional()),
|
|
28
|
-
tslib_1.__param(0, common_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
|
27
|
+
tslib_1.__param(0, (0, common_1.Optional)()),
|
|
28
|
+
tslib_1.__param(0, (0, common_1.Inject)(files_constants_1.MULTER_MODULE_OPTIONS)),
|
|
29
29
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
30
|
], MixinInterceptor);
|
|
31
|
-
const Interceptor = common_1.mixin(MixinInterceptor);
|
|
31
|
+
const Interceptor = (0, common_1.mixin)(MixinInterceptor);
|
|
32
32
|
return Interceptor;
|
|
33
33
|
}
|
|
34
34
|
exports.AnyFilesInterceptor = AnyFilesInterceptor;
|
|
@@ -15,7 +15,7 @@ function FileFieldsInterceptor(uploadFields, localOptions) {
|
|
|
15
15
|
const ctx = context.switchToHttp();
|
|
16
16
|
await new Promise((resolve, reject) => this.multer.fields(uploadFields)(ctx.getRequest(), ctx.getResponse(), (err) => {
|
|
17
17
|
if (err) {
|
|
18
|
-
const error = multer_utils_1.transformException(err);
|
|
18
|
+
const error = (0, multer_utils_1.transformException)(err);
|
|
19
19
|
return reject(error);
|
|
20
20
|
}
|
|
21
21
|
resolve();
|
|
@@ -24,11 +24,11 @@ function FileFieldsInterceptor(uploadFields, localOptions) {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
MixinInterceptor = tslib_1.__decorate([
|
|
27
|
-
tslib_1.__param(0, common_1.Optional()),
|
|
28
|
-
tslib_1.__param(0, common_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
|
27
|
+
tslib_1.__param(0, (0, common_1.Optional)()),
|
|
28
|
+
tslib_1.__param(0, (0, common_1.Inject)(files_constants_1.MULTER_MODULE_OPTIONS)),
|
|
29
29
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
30
|
], MixinInterceptor);
|
|
31
|
-
const Interceptor = common_1.mixin(MixinInterceptor);
|
|
31
|
+
const Interceptor = (0, common_1.mixin)(MixinInterceptor);
|
|
32
32
|
return Interceptor;
|
|
33
33
|
}
|
|
34
34
|
exports.FileFieldsInterceptor = FileFieldsInterceptor;
|
|
@@ -15,7 +15,7 @@ function FileInterceptor(fieldName, localOptions) {
|
|
|
15
15
|
const ctx = context.switchToHttp();
|
|
16
16
|
await new Promise((resolve, reject) => this.multer.single(fieldName)(ctx.getRequest(), ctx.getResponse(), (err) => {
|
|
17
17
|
if (err) {
|
|
18
|
-
const error = multer_utils_1.transformException(err);
|
|
18
|
+
const error = (0, multer_utils_1.transformException)(err);
|
|
19
19
|
return reject(error);
|
|
20
20
|
}
|
|
21
21
|
resolve();
|
|
@@ -24,11 +24,11 @@ function FileInterceptor(fieldName, localOptions) {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
MixinInterceptor = tslib_1.__decorate([
|
|
27
|
-
tslib_1.__param(0, common_1.Optional()),
|
|
28
|
-
tslib_1.__param(0, common_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
|
27
|
+
tslib_1.__param(0, (0, common_1.Optional)()),
|
|
28
|
+
tslib_1.__param(0, (0, common_1.Inject)(files_constants_1.MULTER_MODULE_OPTIONS)),
|
|
29
29
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
30
|
], MixinInterceptor);
|
|
31
|
-
const Interceptor = common_1.mixin(MixinInterceptor);
|
|
31
|
+
const Interceptor = (0, common_1.mixin)(MixinInterceptor);
|
|
32
32
|
return Interceptor;
|
|
33
33
|
}
|
|
34
34
|
exports.FileInterceptor = FileInterceptor;
|
|
@@ -15,7 +15,7 @@ function FilesInterceptor(fieldName, maxCount, localOptions) {
|
|
|
15
15
|
const ctx = context.switchToHttp();
|
|
16
16
|
await new Promise((resolve, reject) => this.multer.array(fieldName, maxCount)(ctx.getRequest(), ctx.getResponse(), (err) => {
|
|
17
17
|
if (err) {
|
|
18
|
-
const error = multer_utils_1.transformException(err);
|
|
18
|
+
const error = (0, multer_utils_1.transformException)(err);
|
|
19
19
|
return reject(error);
|
|
20
20
|
}
|
|
21
21
|
resolve();
|
|
@@ -24,11 +24,11 @@ function FilesInterceptor(fieldName, maxCount, localOptions) {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
MixinInterceptor = tslib_1.__decorate([
|
|
27
|
-
tslib_1.__param(0, common_1.Optional()),
|
|
28
|
-
tslib_1.__param(0, common_1.Inject(files_constants_1.MULTER_MODULE_OPTIONS)),
|
|
27
|
+
tslib_1.__param(0, (0, common_1.Optional)()),
|
|
28
|
+
tslib_1.__param(0, (0, common_1.Inject)(files_constants_1.MULTER_MODULE_OPTIONS)),
|
|
29
29
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
30
|
], MixinInterceptor);
|
|
31
|
-
const Interceptor = common_1.mixin(MixinInterceptor);
|
|
31
|
+
const Interceptor = (0, common_1.mixin)(MixinInterceptor);
|
|
32
32
|
return Interceptor;
|
|
33
33
|
}
|
|
34
34
|
exports.FilesInterceptor = FilesInterceptor;
|
package/multer/multer.module.js
CHANGED
|
@@ -15,7 +15,7 @@ let MulterModule = MulterModule_1 = class MulterModule {
|
|
|
15
15
|
{ provide: files_constants_1.MULTER_MODULE_OPTIONS, useValue: options },
|
|
16
16
|
{
|
|
17
17
|
provide: multer_constants_1.MULTER_MODULE_ID,
|
|
18
|
-
useValue: random_string_generator_util_1.randomStringGenerator(),
|
|
18
|
+
useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
|
|
19
19
|
},
|
|
20
20
|
],
|
|
21
21
|
exports: [files_constants_1.MULTER_MODULE_OPTIONS],
|
|
@@ -29,7 +29,7 @@ let MulterModule = MulterModule_1 = class MulterModule {
|
|
|
29
29
|
...this.createAsyncProviders(options),
|
|
30
30
|
{
|
|
31
31
|
provide: multer_constants_1.MULTER_MODULE_ID,
|
|
32
|
-
useValue: random_string_generator_util_1.randomStringGenerator(),
|
|
32
|
+
useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
|
|
33
33
|
},
|
|
34
34
|
],
|
|
35
35
|
exports: [files_constants_1.MULTER_MODULE_OPTIONS],
|
|
@@ -63,6 +63,6 @@ let MulterModule = MulterModule_1 = class MulterModule {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
MulterModule = MulterModule_1 = tslib_1.__decorate([
|
|
66
|
-
common_1.Module({})
|
|
66
|
+
(0, common_1.Module)({})
|
|
67
67
|
], MulterModule);
|
|
68
68
|
exports.MulterModule = MulterModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/platform-express",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@platform-express)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"body-parser": "1.19.
|
|
20
|
+
"body-parser": "1.19.2",
|
|
21
21
|
"cors": "2.8.5",
|
|
22
|
-
"express": "4.17.
|
|
22
|
+
"express": "4.17.3",
|
|
23
23
|
"multer": "1.4.4",
|
|
24
24
|
"tslib": "2.3.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@nestjs/common": "8.
|
|
28
|
-
"@nestjs/core": "8.
|
|
27
|
+
"@nestjs/common": "8.4.2",
|
|
28
|
+
"@nestjs/core": "8.4.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@nestjs/common": "^8.0.0",
|
package/CHANGELOG.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
<a name="8.2.0"></a>
|
|
7
|
-
# [8.2.0](https://github.com/nestjs/nest/compare/v8.1.2...v8.2.0) (2021-11-08)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
### Features
|
|
11
|
-
|
|
12
|
-
* **common:** add the ability to set some extra metadata about returned files ([5100573](https://github.com/nestjs/nest/commit/5100573))
|