@nestjs/platform-fastify 9.0.4 → 9.0.7

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 CHANGED
@@ -37,8 +37,8 @@ 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:
41
- * チェックするには [ガイド](readme_jp.md), 詳しくは [docs.nestjs.com](https://docs.nestjs.com). :books:
40
+ * [가이드](readme_kr.md) 문서는 [docs.nestjs.com](https://docs.nestjs.com)에서 확인하실 수 있습니다. :books:
41
+ * [ガイド](readme_jp.md) [docs.nestjs.com](https://docs.nestjs.com)でご確認ください。 :books:
42
42
 
43
43
  ## Questions
44
44
 
@@ -97,7 +97,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
97
97
  <a href="https://www.swingdev.io" target="_blank"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="110" valign="middle" /> </a></td><td align="center" valign="middle">
98
98
  <a href="https://www.novologic.com/" target="_blank"><img src="https://nestjs.com/img/novologic.png" width="110" valign="middle" /></a> </td><td align="center" valign="middle">
99
99
  <a href="https://ever.co/" target="_blank"><img src="https://nestjs.com/img/ever-logo.png" width="72" valign="middle" /></a> </td><td align="center" valign="middle">
100
- <a href="https://blokt.com" target="_blank"><img src="https://nestjs.com/img/blokt-logo.png" width="120" valign="middle" /></a> </td><td align="center" valign="middle">
100
+ <a href="https://blokt.com" target="_blank"><img src="https://nestjs.com/img/blokt-logo.png" width="120" valign="middle" /></a> </td><td align="center" valign="middle">
101
101
  <a href="http://architectnow.net/" target="_blank"><img src="https://nestjs.com/img/architectnow.png" width="125" valign="middle" /></a> </td><td align="center" valign="middle">
102
102
  <a href="https://quander.io/" target="_blank"><img src="https://nestjs.com/img/quander.png" width="100" valign="middle" /></a> </td></tr><tr><td align="center" valign="middle">
103
103
  <a href="https://mantro.net/" target="_blank"><img src="https://nestjs.com/img/mantro-logo.svg" width="95" valign="middle" /></a> </td><td align="center" valign="middle">
@@ -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 registerContentParserWithRawBody;
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.register(Promise.resolve().then(() => require('@fastify/formbody')));
250
- if (rawBody) {
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
- registerContentParserWithRawBody() {
280
- this.getInstance().addContentTypeParser('application/json', { parseAs: 'buffer' }, (req, body, done) => {
281
- if (Buffer.isBuffer(body)) {
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.4",
3
+ "version": "9.0.7",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -20,8 +20,8 @@
20
20
  "@fastify/cors": "8.0.0",
21
21
  "@fastify/formbody": "7.0.1",
22
22
  "@fastify/middie": "8.0.0",
23
- "fastify": "4.2.1",
24
- "light-my-request": "5.1.0",
23
+ "fastify": "4.3.0",
24
+ "light-my-request": "5.3.0",
25
25
  "path-to-regexp": "3.2.0",
26
26
  "tslib": "2.4.0"
27
27
  },