@nestjs/platform-fastify 9.0.4 → 9.0.5
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.
|
@@ -86,7 +86,8 @@ export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDef
|
|
|
86
86
|
default: FastifyPluginAsync<any>;
|
|
87
87
|
}>, prefix?: string): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyLoggerInstance, import("fastify").FastifyTypeProviderDefault> & PromiseLike<undefined>;
|
|
88
88
|
private isNativeResponse;
|
|
89
|
-
private
|
|
89
|
+
private registerJsonContentParser;
|
|
90
|
+
private registerUrlencodedContentParser;
|
|
90
91
|
private registerMiddie;
|
|
91
92
|
private getRequestOriginalUrl;
|
|
92
93
|
private injectConstraintsIfVersioned;
|
|
@@ -7,6 +7,8 @@ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
|
7
7
|
const http_adapter_1 = require("@nestjs/core/adapters/http-adapter");
|
|
8
8
|
const fastify_1 = require("fastify");
|
|
9
9
|
const Reply = require("fastify/lib/reply");
|
|
10
|
+
// `querystring` is used internally in fastify for registering urlencoded body parser.
|
|
11
|
+
const querystring_1 = require("querystring");
|
|
10
12
|
class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
11
13
|
constructor(instanceOrOptions) {
|
|
12
14
|
super();
|
|
@@ -246,10 +248,8 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
246
248
|
if (this._isParserRegistered) {
|
|
247
249
|
return;
|
|
248
250
|
}
|
|
249
|
-
this.
|
|
250
|
-
|
|
251
|
-
this.registerContentParserWithRawBody();
|
|
252
|
-
}
|
|
251
|
+
this.registerUrlencodedContentParser(rawBody);
|
|
252
|
+
this.registerJsonContentParser(rawBody);
|
|
253
253
|
this._isParserRegistered = true;
|
|
254
254
|
}
|
|
255
255
|
async createMiddlewareFactory(requestMethod) {
|
|
@@ -276,9 +276,10 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
276
276
|
isNativeResponse(response) {
|
|
277
277
|
return !('status' in response);
|
|
278
278
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
registerJsonContentParser(rawBody) {
|
|
280
|
+
const { bodyLimit } = this.getInstance().initialConfig;
|
|
281
|
+
this.getInstance().addContentTypeParser('application/json', { parseAs: 'buffer', bodyLimit }, (req, body, done) => {
|
|
282
|
+
if (rawBody === true && Buffer.isBuffer(body)) {
|
|
282
283
|
req.rawBody = body;
|
|
283
284
|
}
|
|
284
285
|
const { onProtoPoisoning, onConstructorPoisoning } = this.instance.initialConfig;
|
|
@@ -286,6 +287,15 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
286
287
|
defaultJsonParser(req, body, done);
|
|
287
288
|
});
|
|
288
289
|
}
|
|
290
|
+
registerUrlencodedContentParser(rawBody) {
|
|
291
|
+
const { bodyLimit } = this.getInstance().initialConfig;
|
|
292
|
+
this.getInstance().addContentTypeParser('application/x-www-form-urlencoded', { parseAs: 'buffer', bodyLimit }, (req, body, done) => {
|
|
293
|
+
if (rawBody === true && Buffer.isBuffer(body)) {
|
|
294
|
+
req.rawBody = body;
|
|
295
|
+
}
|
|
296
|
+
done(null, (0, querystring_1.parse)(body.toString()));
|
|
297
|
+
});
|
|
298
|
+
}
|
|
289
299
|
async registerMiddie() {
|
|
290
300
|
this.isMiddieRegistered = true;
|
|
291
301
|
await this.register(Promise.resolve().then(() => require('@fastify/middie')));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/platform-fastify",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.5",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@fastify/formbody": "7.0.1",
|
|
22
22
|
"@fastify/middie": "8.0.0",
|
|
23
23
|
"fastify": "4.2.1",
|
|
24
|
-
"light-my-request": "5.
|
|
24
|
+
"light-my-request": "5.2.0",
|
|
25
25
|
"path-to-regexp": "3.2.0",
|
|
26
26
|
"tslib": "2.4.0"
|
|
27
27
|
},
|