@nestjs/platform-fastify 10.2.10 → 10.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/Readme.md +4 -1
- package/adapters/fastify-adapter.js +9 -5
- package/constants.d.ts +1 -0
- package/constants.js +2 -1
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +1 -0
- package/decorators/route-constraints.decorator.d.ts +7 -0
- package/decorators/route-constraints.decorator.js +12 -0
- package/package.json +3 -3
package/Readme.md
CHANGED
|
@@ -83,7 +83,10 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
83
83
|
<a href="https://fuseautotech.com/" target="_blank"><img src="https://nestjs.com/img/fuse-logo.svg" width="105" valign="middle" /></a></td>
|
|
84
84
|
<td>
|
|
85
85
|
<a href="https://ridicorp.com/career/" target="_blank"><img src="https://nestjs.com/img/ridi-logo.svg" width="105" valign="middle" /></a></td><td>
|
|
86
|
-
<a href="https://www.movavi.com/imovie-for-windows.html" target="_blank"><img src="https://nestjs.com/img/movavi-logo.svg" width="105" valign="middle" /></a></td
|
|
86
|
+
<a href="https://www.movavi.com/imovie-for-windows.html" target="_blank"><img src="https://nestjs.com/img/movavi-logo.svg" width="105" valign="middle" /></a></td>
|
|
87
|
+
</tr><tr><td>
|
|
88
|
+
<a href="https://skunk.team" target="_blank"><img src="https://nestjs.com/img/skunk-logo.png" height="60" valign="middle" /></a></td>
|
|
89
|
+
</tr></table>
|
|
87
90
|
|
|
88
91
|
#### Silver Sponsors
|
|
89
92
|
|
|
@@ -359,16 +359,20 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
359
359
|
const isVersioned = !(0, shared_utils_1.isUndefined)(handlerRef.version) &&
|
|
360
360
|
handlerRef.version !== common_1.VERSION_NEUTRAL;
|
|
361
361
|
const routeConfig = Reflect.getMetadata(constants_1.FASTIFY_ROUTE_CONFIG_METADATA, handlerRef);
|
|
362
|
+
const routeConstraints = Reflect.getMetadata(constants_1.FASTIFY_ROUTE_CONSTRAINTS_METADATA, handlerRef);
|
|
362
363
|
const hasConfig = !(0, shared_utils_1.isUndefined)(routeConfig);
|
|
363
|
-
|
|
364
|
+
const hasConstraints = !(0, shared_utils_1.isUndefined)(routeConstraints);
|
|
365
|
+
if (isVersioned || hasConstraints || hasConfig) {
|
|
364
366
|
const isPathAndRouteTuple = args.length === 2;
|
|
365
367
|
if (isPathAndRouteTuple) {
|
|
366
|
-
const
|
|
368
|
+
const constraints = {
|
|
369
|
+
...(hasConstraints && routeConstraints),
|
|
367
370
|
...(isVersioned && {
|
|
368
|
-
|
|
369
|
-
version: handlerRef.version,
|
|
370
|
-
},
|
|
371
|
+
version: handlerRef.version,
|
|
371
372
|
}),
|
|
373
|
+
};
|
|
374
|
+
const options = {
|
|
375
|
+
constraints,
|
|
372
376
|
...(hasConfig && {
|
|
373
377
|
config: {
|
|
374
378
|
...routeConfig,
|
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FASTIFY_ROUTE_CONFIG_METADATA = void 0;
|
|
3
|
+
exports.FASTIFY_ROUTE_CONSTRAINTS_METADATA = exports.FASTIFY_ROUTE_CONFIG_METADATA = void 0;
|
|
4
4
|
exports.FASTIFY_ROUTE_CONFIG_METADATA = '__fastify_route_config__';
|
|
5
|
+
exports.FASTIFY_ROUTE_CONSTRAINTS_METADATA = '__fastify_route_constraints__';
|
package/decorators/index.d.ts
CHANGED
package/decorators/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RouteShorthandOptions } from 'fastify';
|
|
2
|
+
/**
|
|
3
|
+
* @publicApi
|
|
4
|
+
*
|
|
5
|
+
* @param config See {@link https://fastify.dev/docs/latest/Reference/Routes/#constraints}
|
|
6
|
+
*/
|
|
7
|
+
export declare const RouteConstraints: (config: RouteShorthandOptions['config']) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouteConstraints = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
/**
|
|
7
|
+
* @publicApi
|
|
8
|
+
*
|
|
9
|
+
* @param config See {@link https://fastify.dev/docs/latest/Reference/Routes/#constraints}
|
|
10
|
+
*/
|
|
11
|
+
const RouteConstraints = (config) => (0, common_1.SetMetadata)(constants_1.FASTIFY_ROUTE_CONSTRAINTS_METADATA, config);
|
|
12
|
+
exports.RouteConstraints = RouteConstraints;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/platform-fastify",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@fastify/cors": "8.4.
|
|
21
|
+
"@fastify/cors": "8.4.2",
|
|
22
22
|
"@fastify/formbody": "7.4.0",
|
|
23
23
|
"@fastify/middie": "8.3.0",
|
|
24
|
-
"fastify": "4.
|
|
24
|
+
"fastify": "4.25.1",
|
|
25
25
|
"light-my-request": "5.11.0",
|
|
26
26
|
"path-to-regexp": "3.2.0",
|
|
27
27
|
"tslib": "2.6.2"
|