@nestjs/platform-fastify 8.2.6 → 8.4.0

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>
@@ -84,7 +84,8 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
84
84
  <a href="https://www.myleodsc.com/" target="_blank"><img src="https://nestjs.com/img/myleo-logo.png" width="180" valign="middle" /></td><td>
85
85
  <a href="https://careers.meetdandy.com/?gh_src=063ba61e3us" target="_blank"><img src="https://nestjs.com/img/dandy-roles-logo.svg" width="150" valign="middle" /></td><td>
86
86
  <a href="https://www.castlecraft.in" target="_blank"><img src="https://nestjs.com/img/castlecraft-logo.png" width="150" valign="middle" /></td>
87
- <td><a href="https://www.tinystacks.com" target="_blank"><img src="https://nestjs.com/img/tinystacks-logo.png#1" width="140" valign="middle" /></td></tr></table>
87
+ <td><a href="https://www.tinystacks.com" target="_blank"><img src="https://nestjs.com/img/tinystacks-logo.png#1" width="140" valign="middle" /></td>
88
+ <td><a href="https://n.inc" target="_blank"><img src="https://nestjs.com/img/n-inc-logo.svg" width="120" valign="middle" /></td></tr></table>
88
89
 
89
90
  #### Sponsors
90
91
 
@@ -118,6 +119,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
118
119
  <td align="center" valign="middle"><a href="https://www.naologic.com/" target="_blank"><img src="https://nestjs.com/img/naologic-logo.svg" width="125" valign="middle" /></a></td>
119
120
  <td align="center" valign="middle"><a href="https://messaged.com/" target="_blank"><img src="https://nestjs.com/img/messaged-logo.png" width="50" valign="middle" /></a></td>
120
121
  <td align="center" valign="middle"><a href="https://triplecore.io" target="_blank"><img src="https://nestjs.com/img/triplecore-logo.svg" width="50" valign="middle" /></a></td>
122
+ <td align="center" valign="middle"><a href="https://klqc.de" target="_blank"><img src="https://nestjs.com/img/klcqcl-logo.png" width="120" valign="middle" /></a></td>
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
+ <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
+ <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>
121
127
  </tr></table>
122
128
 
123
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);
@@ -224,9 +242,11 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
224
242
  await this.registerMiddie();
225
243
  }
226
244
  return (path, callback) => {
227
- const normalizedPath = path.endsWith('/*')
245
+ let normalizedPath = path.endsWith('/*')
228
246
  ? `${path.slice(0, -1)}(.*)`
229
247
  : path;
248
+ // Fallback to "(.*)" to support plugins like GraphQL
249
+ normalizedPath = normalizedPath === '/(.*)' ? '(.*)' : normalizedPath;
230
250
  // The following type assertion is valid as we use import('middie') rather than require('middie')
231
251
  // ref https://github.com/fastify/middie/pull/55
232
252
  this.instance.use(normalizedPath, callback);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/platform-fastify",
3
- "version": "8.2.6",
3
+ "version": "8.4.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -17,11 +17,11 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "fastify": "3.27.0",
21
- "fastify-cors": "6.0.2",
20
+ "fastify": "3.27.2",
21
+ "fastify-cors": "6.0.3",
22
22
  "fastify-formbody": "5.2.0",
23
- "light-my-request": "4.7.0",
24
- "middie": "5.3.0",
23
+ "light-my-request": "4.8.0",
24
+ "middie": "6.0.0",
25
25
  "path-to-regexp": "3.2.0",
26
26
  "tslib": "2.3.1"
27
27
  },
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))