@nestjs/platform-express 12.0.0-alpha.4 → 12.0.0-alpha.6
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 +25 -45
- package/adapters/express-adapter.d.ts +3 -3
- package/adapters/express-adapter.js +16 -8
- package/adapters/utils/get-body-parser-options.util.d.ts +2 -2
- package/adapters/utils/get-body-parser-options.util.js +4 -5
- package/interfaces/nest-express-application.interface.d.ts +7 -3
- package/interfaces/nest-express-body-parser-options.interface.d.ts +6 -0
- package/interfaces/nest-express-body-parser.interface.d.ts +27 -1
- package/multer/multer/multer.constants.d.ts +1 -0
- package/multer/multer/multer.constants.js +1 -0
- package/multer/multer/multer.utils.js +1 -0
- package/package.json +5 -5
package/Readme.md
CHANGED
|
@@ -59,11 +59,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
59
59
|
|
|
60
60
|
<table style="text-align:center;">
|
|
61
61
|
<tr>
|
|
62
|
-
<td><a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
|
63
|
-
<td><a href="https://microsoft.com/" target="_blank"><img src="https://nestjs.com/img/
|
|
64
|
-
<td><a href="https://mojam.co" target="_blank"><img src="https://
|
|
62
|
+
<td><a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/github/trilon-logo.svg" width="200" valign="middle" /></a></td>
|
|
63
|
+
<td><a href="https://microsoft.com/" target="_blank"><img src="https://nestjs.com/img/github/microsoft-logo.png" width="180" valign="middle" /></a></td>
|
|
64
|
+
<td><a href="https://mojam.co" target="_blank"><img src="https://images.opencollective.com/mojamco/981e9de/logo/256.png?height=256" width="80" valign="middle" /></a></td>
|
|
65
65
|
<td><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>
|
|
66
|
-
<td><a href="https://serpapi.com/" target="_blank"><img src="https://nestjs.com/img/
|
|
66
|
+
<td><a href="https://serpapi.com/" target="_blank"><img src="https://nestjs.com/img/github/serpapi-logo.png" width="150" valign="middle" /></a></td>
|
|
67
67
|
</tr>
|
|
68
68
|
</table>
|
|
69
69
|
|
|
@@ -71,15 +71,15 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
71
71
|
|
|
72
72
|
<table style="text-align:center;">
|
|
73
73
|
<tr>
|
|
74
|
-
<td><a href="https://www.redhat.com" target="_blank"><img src="https://nestjs.com/img/
|
|
75
|
-
<td><a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="
|
|
76
|
-
<td><a href="https://nx.dev" target="_blank"><img src="https://nestjs.com/img/
|
|
77
|
-
<td><a href="https://intrinsic.ventures/" target="_blank"><img src="https://nestjs.com/img/
|
|
78
|
-
<td><a href="https://jetbrains.com/" target="_blank"><img src="https://nestjs.com/img/
|
|
74
|
+
<td><a href="https://www.redhat.com" target="_blank"><img src="https://nestjs.com/img/github/red-hat-logo.svg" width="150" valign="middle" /></a></td>
|
|
75
|
+
<td><a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="120" valign="middle" /></a></td>
|
|
76
|
+
<td><a href="https://nx.dev" target="_blank"><img src="https://nestjs.com/img/github/nx-logo.png" height="45" valign="middle" /></a></td>
|
|
77
|
+
<td><a href="https://intrinsic.ventures/" target="_blank"><img src="https://nestjs.com/img/github/intrinisic-logo.png" width="150" valign="middle" /></a></td>
|
|
78
|
+
<td><a href="https://jetbrains.com/" target="_blank"><img src="https://nestjs.com/img/github/jetbrains-logo.svg" width="70" valign="middle" /></a></td>
|
|
79
79
|
</tr>
|
|
80
80
|
<tr>
|
|
81
|
-
<td><a href="https://snyk.co/nestjs" target="_blank"><img src="https://nestjs.com/img/
|
|
82
|
-
<td><a href="https://www.movavi.com/imovie-for-windows.html" target="_blank"><img src="https://
|
|
81
|
+
<td><a href="https://snyk.co/nestjs" target="_blank"><img src="https://nestjs.com/img/github/snyk-logo-black.png" width="125" valign="middle" /></a></td>
|
|
82
|
+
<td align="center"><a href="https://www.movavi.com/imovie-for-windows.html" target="_blank"><img src="https://images.opencollective.com/movavi/1fb15e5/avatar/256.png?height=256" width="60" valign="middle" /></a></td>
|
|
83
83
|
</tr>
|
|
84
84
|
</table>
|
|
85
85
|
|
|
@@ -87,15 +87,15 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
87
87
|
|
|
88
88
|
<table style="text-align:center;">
|
|
89
89
|
<tr>
|
|
90
|
-
<td><a href="https://www.mercedes-benz.com/" target="_blank"><img src="https://nestjs.com/img/
|
|
91
|
-
<td><a href="https://
|
|
92
|
-
<td><a href="https://
|
|
93
|
-
<td align="center" valign="middle"><a href="https://
|
|
94
|
-
<td align="center" valign="middle"><a href="https://
|
|
95
|
-
<td align="center" valign="middle"><a href="https://crawljobs.com" target="_blank"><img src="https://nestjs.com/img/logos/crawljobs-logo.svg" width="130" valign="middle" /></a></td>
|
|
90
|
+
<td><a href="https://www.mercedes-benz.com/" target="_blank"><img src="https://nestjs.com/img/github/mercedes-logo.png" width="100" valign="middle" /></a></td>
|
|
91
|
+
<td><a href="https://handsontable.com/docs/react-data-grid/?utm_source=NestJS_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship_2024" target="_blank"><img src="https://nestjs.com/img/github/handsontable-dark-logo.svg#2" width="150" valign="middle" /></a></td>
|
|
92
|
+
<td align="center" valign="middle"><a href="https://www.itflashcards.com/" target="_blank"><img src="https://nestjs.com/img/github/it_flashcards-logo.png" width="170" valign="middle" /></a></td>
|
|
93
|
+
<td align="center" valign="middle"><a href="https://arcjet.com/?ref=nestjs" target="_blank"><img src="https://nestjs.com/img/github/arcjet-logo.svg" width="170" valign="middle" /></a></td>
|
|
94
|
+
<td align="center" valign="middle"><a href="https://pandektes.com" target="_blank"><img src="https://nestjs.com/img/github/pandektes-logo.png" width="65" valign="middle" /></a></td>
|
|
96
95
|
</tr><tr>
|
|
97
|
-
<td align="center" valign="middle"><a href="https://
|
|
98
|
-
<td align="center" valign="middle"><a href="https://
|
|
96
|
+
<td align="center" valign="middle"><a href="https://www.fintechcrafts.com/" target="_blank"><img src="https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/935813df-48a9-4b41-b923-7d70b5621c6b/2026-05-06%2010%2021%2033.png" width="65" valign="middle" /></a></td>
|
|
97
|
+
<td align="center" valign="middle"><a href="https://talordata.com/?campaignid=Ya5Xpw2gmhyee6Tg&utm_source=nestjs&utm_term=nestjs" target="_blank"><img src="https://images.opencollective.com/elowen/9ccac7f/avatar/512.png" width="65" valign="middle" /></a></td>
|
|
98
|
+
<td align="center" valign="middle"><a href="https://memory2.co/" target="_blank"><img src="https://images.opencollective.com/memory-squared/bbe37f5/avatar/256.png?height=50" width="65" valign="middle" /></a></td>
|
|
99
99
|
</tr>
|
|
100
100
|
</table>
|
|
101
101
|
|
|
@@ -103,32 +103,12 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
103
103
|
|
|
104
104
|
<table>
|
|
105
105
|
<tr>
|
|
106
|
-
<td align="center" valign="middle"><a href="https://
|
|
107
|
-
<td align="center" valign="middle"><a href="https://
|
|
108
|
-
<td align="center" valign="middle"><a href="https://
|
|
109
|
-
<td align="center" valign="middle"><a href="https://
|
|
110
|
-
<td align="center" valign="middle"><a href="https://
|
|
111
|
-
<td align="center" valign="middle"><a href="https://
|
|
112
|
-
</tr>
|
|
113
|
-
<tr>
|
|
114
|
-
<td align="center" valign="middle"><a href="https://vpn-review.com/vpn-for-torrenting" target="_blank"><img src="https://nestjs.com/img/logos/vpn-review-logo.png" width="85" valign="middle" /></a></td>
|
|
115
|
-
<td align="center" valign="middle"><a href="https://lambda-it.ch/" target="_blank"><img src="https://nestjs.com/img/logos/lambda-it-logo.svg" width="115" valign="middle" /></a></td>
|
|
116
|
-
<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/logos/rocketech-logo.svg" width="110" valign="middle" /></a></td>
|
|
117
|
-
<td align="center" valign="middle"><a href="https://www.anonymistic.com/" target="_blank"><img src="https://nestjs.com/img/logos/anonymistic-logo.png" width="125" valign="middle" /></a></td>
|
|
118
|
-
<td align="center" valign="middle"><a href="https://www.naologic.com/" target="_blank"><img src="https://nestjs.com/img/logos/naologic-logo.svg" width="125" valign="middle" /></a></td>
|
|
119
|
-
<td align="center" valign="middle"><a href="https://triplecore.io" target="_blank"><img src="https://nestjs.com/img/logos/triplecore-logo.svg" width="50" valign="middle" /></a></td>
|
|
120
|
-
</tr>
|
|
121
|
-
<tr>
|
|
122
|
-
<td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/logos/polygon-logo.svg" width="120" valign="middle" /></a></td>
|
|
123
|
-
<td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/logos/boringowl-logo.svg" width="120" valign="middle" /></a></td>
|
|
124
|
-
<td align="center" valign="middle"><a href="https://nordbot.app/" target="_blank"><img src="https://nestjs.com/img/logos/nordbot-logo.png" width="120" valign="middle" /></a></td>
|
|
125
|
-
<td align="center" valign="middle"><a href="https://doppio.sh/" target="_blank"><img src="https://nestjs.com/img/logos/dopiosh-logo.png" width="50" valign="middle" /></a></td>
|
|
126
|
-
<td align="center" valign="middle"><a href="https://www.hingehealth.com/" target="_blank"><img src="https://nestjs.com/img/logos/hinge-health-logo.svg" width="100" valign="middle" /></a></td>
|
|
127
|
-
<td align="center" valign="middle"><a href="https://www.tripoffice.com/" target="_blank"><img src="https://nestjs.com/img/logos/tripoffice-logo.png" width="140" valign="middle" /></a></td>
|
|
128
|
-
</tr>
|
|
129
|
-
<tr>
|
|
130
|
-
<td align="center" valign="middle"><a href="https://solcellsforetag.se/" target="_blank"><img src="https://nestjs.com/img/logos/solcellsforetag-logo.svg" width="140" valign="middle" /></a></td>
|
|
131
|
-
<td align="center" valign="middle"><a href="https://www.route4me.com/" target="_blank"><img src="https://nestjs.com/img/logos/route4me-logo.svg" width="100" valign="middle" /></a></td>
|
|
106
|
+
<td align="center" valign="middle"><a href="https://mantro.net/" target="_blank"><img src="https://nestjs.com/img/github/mantro-logo.svg" width="95" valign="middle" /></a></td>
|
|
107
|
+
<td align="center" valign="middle"><a href="https://triplebyte.com/" target="_blank"><img src="https://nestjs.com/img/github/triplebyte-logo.png" width="107" valign="middle" /></a></td>
|
|
108
|
+
<td align="center" valign="middle"><a href="https://nearpod.com/" target="_blank"><img src="https://nestjs.com/img/github/nearpod-logo.svg" width="100" valign="middle" /></a></td>
|
|
109
|
+
<td align="center" valign="middle"><a href="https://www.naologic.com/" target="_blank"><img src="https://nestjs.com/img/github/naologic-logo.svg" width="125" valign="middle" /></a></td>
|
|
110
|
+
<td align="center" valign="middle"><a href="https://triplecore.io" target="_blank"><img src="https://nestjs.com/img/github/triplecore-logo.svg" width="50" valign="middle" /></a>
|
|
111
|
+
<td align="center" valign="middle"><a href="https://www.hingehealth.com/" target="_blank"><img src="https://nestjs.com/img/github/hinge-health-logo.svg" width="100" valign="middle" /></a></td>
|
|
132
112
|
</tr>
|
|
133
113
|
</table>
|
|
134
114
|
|
|
@@ -3,8 +3,7 @@ import express from 'express';
|
|
|
3
3
|
import type { Server } from 'http';
|
|
4
4
|
import * as http from 'http';
|
|
5
5
|
import * as https from 'https';
|
|
6
|
-
import {
|
|
7
|
-
import { NestExpressBodyParserType } from '../interfaces/nest-express-body-parser.interface.js';
|
|
6
|
+
import { NestExpressBodyParserOptionsFor, NestExpressBodyParserType } from '../interfaces/nest-express-body-parser.interface.js';
|
|
8
7
|
import { ServeStaticOptions } from '../interfaces/serve-static-options.interface.js';
|
|
9
8
|
import { type CorsOptions, type CorsOptionsDelegate, type VersionValue } from '@nestjs/common/internal';
|
|
10
9
|
import type { NestApplicationOptions } from '@nestjs/common';
|
|
@@ -54,9 +53,10 @@ export declare class ExpressAdapter extends AbstractHttpAdapter<http.Server | ht
|
|
|
54
53
|
createMiddlewareFactory(requestMethod: RequestMethod): (path: string, callback: Function) => any;
|
|
55
54
|
initHttpServer(options: NestApplicationOptions): void;
|
|
56
55
|
registerParserMiddleware(prefix?: string, rawBody?: boolean): void;
|
|
57
|
-
useBodyParser<
|
|
56
|
+
useBodyParser<ParserType extends NestExpressBodyParserType>(type: ParserType, rawBody: boolean, options?: NestExpressBodyParserOptionsFor<ParserType>): this;
|
|
58
57
|
setLocal(key: string, value: any): this;
|
|
59
58
|
getType(): string;
|
|
59
|
+
isRouteOrderSensitive(): boolean;
|
|
60
60
|
applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): VersionedRoute;
|
|
61
61
|
mapException(error: unknown): unknown;
|
|
62
62
|
private trackOpenConnections;
|
|
@@ -42,7 +42,7 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
|
|
42
42
|
this.onResponseHook = onResponseHook;
|
|
43
43
|
}
|
|
44
44
|
reply(response, body, statusCode) {
|
|
45
|
-
if (statusCode) {
|
|
45
|
+
if (!isNil(statusCode)) {
|
|
46
46
|
response.status(statusCode);
|
|
47
47
|
}
|
|
48
48
|
if (isNil(body)) {
|
|
@@ -83,8 +83,11 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
|
|
83
83
|
if (prefix) {
|
|
84
84
|
const router = express.Router();
|
|
85
85
|
router.use(handler);
|
|
86
|
-
|
|
86
|
+
this.use(prefix, router);
|
|
87
87
|
}
|
|
88
|
+
// Always mount the error handler at the root as well, so routes living
|
|
89
|
+
// outside the global prefix (e.g. "setGlobalPrefix" exclusions or
|
|
90
|
+
// root-mounted routes) still pass through the exception layer.
|
|
88
91
|
return this.use(handler);
|
|
89
92
|
}
|
|
90
93
|
setNotFoundHandler(handler, prefix) {
|
|
@@ -99,8 +102,12 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
|
|
99
102
|
// handler may be registered before a prefixed app's routes. Skip
|
|
100
103
|
// requests whose path belongs to another app's prefix so they can
|
|
101
104
|
// reach the correct route handlers further in the stack.
|
|
105
|
+
const path = req.originalUrl.split(/[?#]/)[0];
|
|
102
106
|
for (const registeredPrefix of this.registeredPrefixes) {
|
|
103
|
-
|
|
107
|
+
// Match on full path segments only, so a prefix of "/api" does not
|
|
108
|
+
// swallow unrelated paths such as "/apiary".
|
|
109
|
+
if (path === registeredPrefix ||
|
|
110
|
+
path.startsWith(`${registeredPrefix}/`)) {
|
|
104
111
|
return next();
|
|
105
112
|
}
|
|
106
113
|
}
|
|
@@ -223,10 +230,8 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
|
|
223
230
|
}
|
|
224
231
|
}
|
|
225
232
|
registerParserMiddleware(prefix, rawBody) {
|
|
226
|
-
const bodyParserJsonOptions = getBodyParserOptions(rawBody);
|
|
227
|
-
const bodyParserUrlencodedOptions = getBodyParserOptions(rawBody, {
|
|
228
|
-
extended: true,
|
|
229
|
-
});
|
|
233
|
+
const bodyParserJsonOptions = getBodyParserOptions('json', rawBody);
|
|
234
|
+
const bodyParserUrlencodedOptions = getBodyParserOptions('urlencoded', rawBody, { extended: true });
|
|
230
235
|
const parserMiddleware = {
|
|
231
236
|
jsonParser: express.json(bodyParserJsonOptions),
|
|
232
237
|
urlencodedParser: express.urlencoded(bodyParserUrlencodedOptions),
|
|
@@ -236,7 +241,7 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
|
|
236
241
|
.forEach(parserKey => this.use(parserMiddleware[parserKey]));
|
|
237
242
|
}
|
|
238
243
|
useBodyParser(type, rawBody, options) {
|
|
239
|
-
const parserOptions = getBodyParserOptions(rawBody, options);
|
|
244
|
+
const parserOptions = getBodyParserOptions(type, rawBody, options);
|
|
240
245
|
const parser = express[type](parserOptions);
|
|
241
246
|
this.use(parser);
|
|
242
247
|
return this;
|
|
@@ -248,6 +253,9 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
|
|
248
253
|
getType() {
|
|
249
254
|
return 'express';
|
|
250
255
|
}
|
|
256
|
+
isRouteOrderSensitive() {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
251
259
|
applyVersionFilter(handler, version, versioningOptions) {
|
|
252
260
|
const callNextHandler = (req, res, next) => {
|
|
253
261
|
if (!next) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function getBodyParserOptions<
|
|
1
|
+
import type { NestExpressBodyParserOptionsFor, NestExpressBodyParserOptionsMap, NestExpressBodyParserType } from '../../interfaces/index.js';
|
|
2
|
+
export declare function getBodyParserOptions<ParserType extends NestExpressBodyParserType>(parser: ParserType, rawBody: boolean, options?: NestExpressBodyParserOptionsFor<ParserType>): NestExpressBodyParserOptionsMap[ParserType];
|
|
@@ -4,13 +4,12 @@ const rawBodyParser = (req, _res, buffer) => {
|
|
|
4
4
|
}
|
|
5
5
|
return true;
|
|
6
6
|
};
|
|
7
|
-
export function getBodyParserOptions(rawBody, options) {
|
|
8
|
-
let parserOptions = (options || {});
|
|
7
|
+
export function getBodyParserOptions(parser, rawBody, options) {
|
|
9
8
|
if (rawBody === true) {
|
|
10
|
-
|
|
11
|
-
...
|
|
9
|
+
return {
|
|
10
|
+
...options,
|
|
12
11
|
verify: rawBodyParser,
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
|
-
return
|
|
14
|
+
return options || {};
|
|
16
15
|
}
|
|
@@ -2,8 +2,7 @@ import type { HttpServer, INestApplication } from '@nestjs/common';
|
|
|
2
2
|
import type { Express } from 'express';
|
|
3
3
|
import type { Server as CoreHttpServer } from 'http';
|
|
4
4
|
import type { Server as CoreHttpsServer } from 'https';
|
|
5
|
-
import {
|
|
6
|
-
import { NestExpressBodyParserType } from './nest-express-body-parser.interface.js';
|
|
5
|
+
import { NestExpressBodyParserOptionsFor, NestExpressBodyParserType } from './nest-express-body-parser.interface.js';
|
|
7
6
|
import { ServeStaticOptions } from './serve-static-options.interface.js';
|
|
8
7
|
import type { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/internal';
|
|
9
8
|
/**
|
|
@@ -85,9 +84,14 @@ export interface NestExpressApplication<TServer extends CoreHttpServer | CoreHtt
|
|
|
85
84
|
* );
|
|
86
85
|
* app.useBodyParser('json', { limit: '50mb' });
|
|
87
86
|
*
|
|
87
|
+
* The accepted options are narrowed by the `parser` argument, so
|
|
88
|
+
* `useBodyParser('json', ...)` only accepts `express.json` options,
|
|
89
|
+
* `useBodyParser('urlencoded', ...)` only accepts `express.urlencoded`
|
|
90
|
+
* options, and so on.
|
|
91
|
+
*
|
|
88
92
|
* @returns {this}
|
|
89
93
|
*/
|
|
90
|
-
useBodyParser<
|
|
94
|
+
useBodyParser<ParserType extends NestExpressBodyParserType>(parser: ParserType, options?: NestExpressBodyParserOptionsFor<ParserType>): this;
|
|
91
95
|
/**
|
|
92
96
|
* Sets one or multiple base directories for templates (views).
|
|
93
97
|
*
|
|
@@ -2,6 +2,12 @@ import type { IncomingMessage } from 'http';
|
|
|
2
2
|
/**
|
|
3
3
|
* Type alias to keep compatibility with @types/body-parser
|
|
4
4
|
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/dcd1673c4fa18a15ea8cd8ff8af7d563bb6dc8e6/types/body-parser/index.d.ts#L48-L66#L48-L66
|
|
5
|
+
*
|
|
6
|
+
* @deprecated Prefer {@link NestExpressBodyParserOptionsFor}, which resolves the
|
|
7
|
+
* exact options type for a given parser. The catch-all index signature below
|
|
8
|
+
* makes `keyof` resolve to `string | number`, which disables excess-property
|
|
9
|
+
* checking and makes `Omit<_, 'verify'>` a no-op.
|
|
10
|
+
*
|
|
5
11
|
* @publicApi
|
|
6
12
|
*/
|
|
7
13
|
export interface NestExpressBodyParserOptions {
|
|
@@ -1,4 +1,30 @@
|
|
|
1
|
+
type Express = typeof import('express');
|
|
2
|
+
/**
|
|
3
|
+
* Maps each body parser to the options object accepted by its Express factory.
|
|
4
|
+
*
|
|
5
|
+
* Derived from `express` itself so the two can never drift: `useBodyParser`
|
|
6
|
+
* ultimately calls `express[parser](options)`.
|
|
7
|
+
*
|
|
8
|
+
* @publicApi
|
|
9
|
+
*/
|
|
10
|
+
export interface NestExpressBodyParserOptionsMap {
|
|
11
|
+
json: NonNullable<Parameters<Express['json']>[0]>;
|
|
12
|
+
urlencoded: NonNullable<Parameters<Express['urlencoded']>[0]>;
|
|
13
|
+
text: NonNullable<Parameters<Express['text']>[0]>;
|
|
14
|
+
raw: NonNullable<Parameters<Express['raw']>[0]>;
|
|
15
|
+
}
|
|
1
16
|
/**
|
|
2
17
|
* Interface defining possible body parser types, to be used with `NestExpressApplication.useBodyParser()`.
|
|
3
18
|
*/
|
|
4
|
-
export type NestExpressBodyParserType =
|
|
19
|
+
export type NestExpressBodyParserType = keyof NestExpressBodyParserOptionsMap;
|
|
20
|
+
/**
|
|
21
|
+
* Options accepted by a given body parser.
|
|
22
|
+
*
|
|
23
|
+
* `verify` is excluded because it is reserved: Nest sets it internally to
|
|
24
|
+
* capture the raw request body when the application is created with
|
|
25
|
+
* `{ rawBody: true }`.
|
|
26
|
+
*
|
|
27
|
+
* @publicApi
|
|
28
|
+
*/
|
|
29
|
+
export type NestExpressBodyParserOptionsFor<ParserType extends NestExpressBodyParserType> = Omit<NestExpressBodyParserOptionsMap[ParserType], 'verify'>;
|
|
30
|
+
export {};
|
|
@@ -8,6 +8,7 @@ export const multerExceptions = {
|
|
|
8
8
|
LIMIT_FIELD_COUNT: 'Too many fields',
|
|
9
9
|
LIMIT_UNEXPECTED_FILE: 'Unexpected field',
|
|
10
10
|
MISSING_FIELD_NAME: 'Field name missing',
|
|
11
|
+
LIMIT_FIELD_NESTING: 'Field name nesting too deep',
|
|
11
12
|
};
|
|
12
13
|
export const busboyExceptions = {
|
|
13
14
|
// from https://github.com/mscdex/busboy/blob/master/lib/types/multipart.js
|
|
@@ -13,6 +13,7 @@ export function transformException(error) {
|
|
|
13
13
|
case multerExceptions.LIMIT_FIELD_KEY:
|
|
14
14
|
case multerExceptions.LIMIT_FIELD_VALUE:
|
|
15
15
|
case multerExceptions.LIMIT_FIELD_COUNT:
|
|
16
|
+
case multerExceptions.LIMIT_FIELD_NESTING:
|
|
16
17
|
case multerExceptions.LIMIT_UNEXPECTED_FILE:
|
|
17
18
|
case multerExceptions.LIMIT_PART_COUNT:
|
|
18
19
|
case multerExceptions.MISSING_FIELD_NAME:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/platform-express",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.6",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@platform-express)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"cors": "2.8.6",
|
|
29
29
|
"express": "5.2.1",
|
|
30
|
-
"multer": "2.
|
|
30
|
+
"multer": "2.2.0",
|
|
31
31
|
"path-to-regexp": "8.4.2",
|
|
32
32
|
"tslib": "2.8.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@nestjs/common": "^12.0.0-alpha.
|
|
36
|
-
"@nestjs/core": "^12.0.0-alpha.
|
|
35
|
+
"@nestjs/common": "^12.0.0-alpha.6",
|
|
36
|
+
"@nestjs/core": "^12.0.0-alpha.6"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@nestjs/common": "^11.0.0",
|
|
40
40
|
"@nestjs/core": "^11.0.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "4c38a5ab100f1d2a0d50602998968a25509525c7"
|
|
43
43
|
}
|