@nestjs/platform-fastify 8.2.3 → 8.3.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2021 Kamil Mysliwiec <https://kamilmysliwiec.com>
3
+ Copyright (c) 2017-2022 Kamil Mysliwiec <https://kamilmysliwiec.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/Readme.md CHANGED
@@ -59,6 +59,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
59
59
  #### Principal Sponsors
60
60
  <table style="text-align:center;"><tr>
61
61
  <td><a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
62
+ <td><a href="https://www.redhat.com" target="_blank"><img src="https://nestjs.com/img/red-hat-logo.svg" width="200" valign="middle" /></a></td>
62
63
  <td>
63
64
  <a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
64
65
  <td>
@@ -80,10 +81,11 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
80
81
  <table style="text-align:center;"><tr><td>
81
82
  <a href="https://neoteric.eu/" target="_blank"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" valign="middle" /></a> </td><td>
82
83
  <a href="http://gojob.com" target="_blank"><img src="http://nestjs.com/img/gojob-logo.png" valign="middle" width="100" /></a> </td><td>
83
- <a href="http://www.leogistics.com" target="_blank"><img src="https://nestjs.com/img/leogistics-logo.jpeg" width="150" valign="middle" /></td><td>
84
+ <a href="https://www.myleodsc.com/" target="_blank"><img src="https://nestjs.com/img/myleo-logo.png" width="180" valign="middle" /></td><td>
84
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>
85
86
  <a href="https://www.castlecraft.in" target="_blank"><img src="https://nestjs.com/img/castlecraft-logo.png" width="150" valign="middle" /></td>
86
- <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>
87
89
 
88
90
  #### Sponsors
89
91
 
@@ -117,6 +119,10 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
117
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>
118
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>
119
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>
120
126
  </tr></table>
121
127
 
122
128
  ## Backers
@@ -4,6 +4,7 @@ exports.FastifyAdapter = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const interfaces_1 = require("@nestjs/common/interfaces");
6
6
  const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
7
+ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
7
8
  const http_adapter_1 = require("@nestjs/core/adapters/http-adapter");
8
9
  const fastify_1 = require("fastify");
9
10
  const Reply = require("fastify/lib/reply");
@@ -13,7 +14,7 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
13
14
  this.versionConstraint = {
14
15
  name: 'version',
15
16
  validate(value) {
16
- if (typeof value !== 'string' && !Array.isArray(value)) {
17
+ if (!(0, shared_utils_1.isString)(value) && !Array.isArray(value)) {
17
18
  throw new Error('Version constraint should be a string or an array of strings.');
18
19
  }
19
20
  },
@@ -66,7 +67,7 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
66
67
  };
67
68
  const instance = instanceOrOptions && instanceOrOptions.server
68
69
  ? instanceOrOptions
69
- : fastify_1.fastify(Object.assign({ constraints: {
70
+ : (0, fastify_1.fastify)(Object.assign({ constraints: {
70
71
  version: this.versionConstraint,
71
72
  } }, instanceOrOptions));
72
73
  this.setInstance(instance);
@@ -187,14 +188,14 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
187
188
  this.httpServer = this.instance.server;
188
189
  }
189
190
  useStaticAssets(options) {
190
- return this.register(load_package_util_1.loadPackage('fastify-static', 'FastifyAdapter.useStaticAssets()', () => require('fastify-static')), options);
191
+ return this.register((0, load_package_util_1.loadPackage)('fastify-static', 'FastifyAdapter.useStaticAssets()', () => require('fastify-static')), options);
191
192
  }
192
193
  setViewEngine(options) {
193
- if (typeof options === 'string') {
194
+ if ((0, shared_utils_1.isString)(options)) {
194
195
  new common_1.Logger('FastifyAdapter').error("setViewEngine() doesn't support a string argument.");
195
196
  process.exit(1);
196
197
  }
197
- return this.register(load_package_util_1.loadPackage('point-of-view', 'FastifyAdapter.setViewEngine()', () => require('point-of-view')), options);
198
+ return this.register((0, load_package_util_1.loadPackage)('point-of-view', 'FastifyAdapter.setViewEngine()', () => require('point-of-view')), options);
198
199
  }
199
200
  setHeader(response, name, value) {
200
201
  return response.header(name, value);
@@ -223,9 +224,11 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
223
224
  await this.registerMiddie();
224
225
  }
225
226
  return (path, callback) => {
226
- const normalizedPath = path.endsWith('/*')
227
+ let normalizedPath = path.endsWith('/*')
227
228
  ? `${path.slice(0, -1)}(.*)`
228
229
  : path;
230
+ // Fallback to "(.*)" to support plugins like GraphQL
231
+ normalizedPath = normalizedPath === '/(.*)' ? '(.*)' : normalizedPath;
229
232
  // The following type assertion is valid as we use import('middie') rather than require('middie')
230
233
  // ref https://github.com/fastify/middie/pull/55
231
234
  this.instance.use(normalizedPath, callback);
@@ -249,7 +252,7 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
249
252
  }
250
253
  injectConstraintsIfVersioned(routerMethodKey, ...args) {
251
254
  const handlerRef = args[args.length - 1];
252
- const isVersioned = typeof handlerRef.version !== 'undefined' &&
255
+ const isVersioned = !(0, shared_utils_1.isUndefined)(handlerRef.version) &&
253
256
  handlerRef.version !== interfaces_1.VERSION_NEUTRAL;
254
257
  if (isVersioned) {
255
258
  const isPathAndRouteTuple = args.length === 2;
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
- tslib_1.__exportStar(require("./fastify-adapter"), exports);
4
+ (0, 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
- tslib_1.__exportStar(require("./adapters"), exports);
11
- tslib_1.__exportStar(require("./interfaces"), exports);
10
+ (0, tslib_1.__exportStar)(require("./adapters"), exports);
11
+ (0, 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
- tslib_1.__exportStar(require("./fastify-static-options.interface"), exports);
5
- tslib_1.__exportStar(require("./point-of-view-options.interface"), exports);
4
+ (0, tslib_1.__exportStar)(require("./fastify-static-options.interface"), exports);
5
+ (0, 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
- tslib_1.__exportStar(require("./nest-fastify-application.interface"), exports);
4
+ (0, 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.2.3",
3
+ "version": "8.3.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.24.0",
20
+ "fastify": "3.27.1",
21
21
  "fastify-cors": "6.0.2",
22
22
  "fastify-formbody": "5.2.0",
23
- "light-my-request": "4.6.0",
24
- "middie": "5.3.0",
23
+ "light-my-request": "4.7.1",
24
+ "middie": "6.0.0",
25
25
  "path-to-regexp": "3.2.0",
26
26
  "tslib": "2.3.1"
27
27
  },