@nestjs/platform-fastify 8.3.0 → 8.4.1

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
@@ -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 by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/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>
@@ -123,6 +123,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
123
123
  <td align="center" valign="middle"><a href="https://thecasinowizard.com/bonuses/no-deposit-bonuses/" target="_blank"><img src="https://nestjs.com/img/casinowizard-logo.png" width="120" valign="middle" /></a></td></tr><tr>
124
124
  <td align="center" valign="middle"><a href="https://polygon-software.ch/" target="_blank"><img src="https://nestjs.com/img/polygon-logo.svg" width="120" valign="middle" /></a></td>
125
125
  <td align="center" valign="middle"><a href="https://mobilereality.pl/" target="_blank"><img src="https://nestjs.com/img/mobile-reality-logo.png" width="45" valign="middle" /></a></td>
126
+ <td align="center" valign="middle"><a href="https://boringowl.io/" target="_blank"><img src="https://nestjs.com/img/boringowl-logo.svg" width="120" valign="middle" /></a></td>
126
127
  </tr></table>
127
128
 
128
129
  ## Backers
@@ -22,17 +22,25 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
22
22
  const versions = new Map();
23
23
  return {
24
24
  get(version) {
25
+ if (Array.isArray(version)) {
26
+ return versions.get(version.find(v => versions.has(v))) || null;
27
+ }
25
28
  return versions.get(version) || null;
26
29
  },
27
30
  set(versionOrVersions, store) {
28
- const storeVersionConstraint = version => versions.set(version, store);
31
+ const storeVersionConstraint = (version) => versions.set(version, store);
29
32
  if (Array.isArray(versionOrVersions))
30
33
  versionOrVersions.forEach(storeVersionConstraint);
31
34
  else
32
35
  storeVersionConstraint(versionOrVersions);
33
36
  },
34
37
  del(version) {
35
- versions.delete(version);
38
+ if (Array.isArray(version)) {
39
+ version.forEach(v => versions.delete(v));
40
+ }
41
+ else {
42
+ versions.delete(version);
43
+ }
36
44
  },
37
45
  empty() {
38
46
  versions.clear();
@@ -61,6 +69,10 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
61
69
  return customHeaderVersionParameter;
62
70
  }
63
71
  }
72
+ // Custom Versioning Handler
73
+ else if (this.versioningOptions.type === common_1.VersioningType.CUSTOM) {
74
+ return this.versioningOptions.extractor(req);
75
+ }
64
76
  return undefined;
65
77
  },
66
78
  mustMatchWhenDerived: false,
@@ -130,12 +142,18 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
130
142
  }
131
143
  if (body instanceof common_1.StreamableFile) {
132
144
  const streamHeaders = body.getHeaders();
133
- if (fastifyReply.getHeader('Content-Type') === undefined) {
145
+ if (fastifyReply.getHeader('Content-Type') === undefined &&
146
+ streamHeaders.type !== undefined) {
134
147
  fastifyReply.header('Content-Type', streamHeaders.type);
135
148
  }
136
- if (fastifyReply.getHeader('Content-Disposition') === undefined) {
149
+ if (fastifyReply.getHeader('Content-Disposition') === undefined &&
150
+ streamHeaders.disposition !== undefined) {
137
151
  fastifyReply.header('Content-Disposition', streamHeaders.disposition);
138
152
  }
153
+ if (fastifyReply.getHeader('Content-Length') === undefined &&
154
+ streamHeaders.length !== undefined) {
155
+ fastifyReply.header('Content-Length', streamHeaders.length);
156
+ }
139
157
  body = body.getStream();
140
158
  }
141
159
  return fastifyReply.send(body);
package/adapters/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./fastify-adapter"), exports);
4
+ tslib_1.__exportStar(require("./fastify-adapter"), exports);
package/index.js CHANGED
@@ -7,5 +7,5 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- (0, tslib_1.__exportStar)(require("./adapters"), exports);
11
- (0, tslib_1.__exportStar)(require("./interfaces"), exports);
10
+ tslib_1.__exportStar(require("./adapters"), exports);
11
+ tslib_1.__exportStar(require("./interfaces"), exports);
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./fastify-static-options.interface"), exports);
5
- (0, tslib_1.__exportStar)(require("./point-of-view-options.interface"), exports);
4
+ tslib_1.__exportStar(require("./fastify-static-options.interface"), exports);
5
+ tslib_1.__exportStar(require("./point-of-view-options.interface"), exports);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./nest-fastify-application.interface"), exports);
4
+ tslib_1.__exportStar(require("./nest-fastify-application.interface"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/platform-fastify",
3
- "version": "8.3.0",
3
+ "version": "8.4.1",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -17,10 +17,10 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "fastify": "3.27.1",
21
- "fastify-cors": "6.0.2",
20
+ "fastify": "3.27.4",
21
+ "fastify-cors": "6.0.3",
22
22
  "fastify-formbody": "5.2.0",
23
- "light-my-request": "4.7.1",
23
+ "light-my-request": "4.8.0",
24
24
  "middie": "6.0.0",
25
25
  "path-to-regexp": "3.2.0",
26
26
  "tslib": "2.3.1"
package/CHANGELOG.md DELETED
@@ -1,18 +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
- ### Bug Fixes
11
-
12
- * **deps:** update dependency fastify to v3.23.1 ([63113d8](https://github.com/nestjs/nest/commit/63113d8))
13
- * **platform-fastify:** fix streamable file processing ([365c40b](https://github.com/nestjs/nest/commit/365c40b))
14
-
15
-
16
- ### Features
17
-
18
- * **common:** add the ability to set some extra metadata about returned files ([5100573](https://github.com/nestjs/nest/commit/5100573))