@nestjs/platform-fastify 10.1.3 → 10.2.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 +14 -11
- package/adapters/fastify-adapter.d.ts +1 -1
- package/adapters/fastify-adapter.js +22 -12
- package/constants.d.ts +1 -0
- package/constants.js +4 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +4 -0
- package/decorators/route-config.decorator.d.ts +4 -0
- package/decorators/route-config.decorator.js +10 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
## Description
|
|
25
25
|
|
|
26
|
-
Nest is a framework for building efficient, scalable <a href="https://nodejs.org" target="_blank">Node.js</a> server-side applications. It uses modern JavaScript, is built with
|
|
26
|
+
Nest is a framework for building efficient, scalable <a href="https://nodejs.org" target="_blank">Node.js</a> server-side applications. It uses modern JavaScript, is built with <a href="https://www.typescriptlang.org" target="_blank">TypeScript</a> (preserves compatibility with pure JavaScript) and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
|
|
27
27
|
|
|
28
28
|
<p>Under the hood, Nest makes use of <a href="https://expressjs.com/" target="_blank">Express</a>, but also, provides compatibility with a wide range of other libraries, like e.g. <a href="https://github.com/fastify/fastify" target="_blank">Fastify</a>, allowing for easy use of the myriad third-party plugins which are available.</p>
|
|
29
29
|
|
|
@@ -34,10 +34,10 @@ Nest is a framework for building efficient, scalable <a href="https://nodejs.org
|
|
|
34
34
|
|
|
35
35
|
## Getting started
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
- To check out the [guide](https://docs.nestjs.com), visit [docs.nestjs.com](https://docs.nestjs.com). :books:
|
|
38
|
+
- 要查看中文 [指南](readme_zh.md), 请访问 [docs.nestjs.cn](https://docs.nestjs.cn). :books:
|
|
39
|
+
- [가이드](readme_kr.md) 문서는 [docs.nestjs.com](https://docs.nestjs.com)에서 확인하실 수 있습니다. :books:
|
|
40
|
+
- [ガイド](readme_jp.md)は [docs.nestjs.com](https://docs.nestjs.com)でご確認ください。 :books:
|
|
41
41
|
|
|
42
42
|
## Questions
|
|
43
43
|
|
|
@@ -56,10 +56,13 @@ With official support, you can get expert help straight from Nest core team. We
|
|
|
56
56
|
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).
|
|
57
57
|
|
|
58
58
|
#### Principal Sponsors
|
|
59
|
+
|
|
59
60
|
<table style="text-align:center;"><tr>
|
|
60
61
|
<td><a href="https://trilon.io" target="_blank"><img src="https://nestjs.com/img/trilon.svg" width="200" valign="middle" /></a></td>
|
|
61
62
|
<td>
|
|
62
63
|
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td>
|
|
64
|
+
<td>
|
|
65
|
+
<a href="https://amplication.com/" target="_blank"><img src="https://nestjs.com/img/amplication-logo.svg" width="190" valign="middle" /></a></td>
|
|
63
66
|
</tr></table>
|
|
64
67
|
|
|
65
68
|
#### Gold Sponsors
|
|
@@ -69,8 +72,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
69
72
|
<td>
|
|
70
73
|
<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>
|
|
71
74
|
<td>
|
|
72
|
-
<a href="https://nx.dev" target="_blank"><img src="https://nestjs.com/img/nx-logo.png" height="45" valign="middle" /></a></td
|
|
73
|
-
<a href="https://amplication.com/" target="_blank"><img src="https://nestjs.com/img/amplication-logo.svg" width="190" valign="middle" /></a></td>
|
|
75
|
+
<a href="https://nx.dev" target="_blank"><img src="https://nestjs.com/img/nx-logo.png" height="45" valign="middle" /></a></td>
|
|
74
76
|
<td>
|
|
75
77
|
<a href="https://weld.app/" target="_blank"><img src="https://nestjs.com/img/weld-logo.svg" width="140" valign="middle" /></a></td>
|
|
76
78
|
<td>
|
|
@@ -86,7 +88,8 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
86
88
|
#### Silver Sponsors
|
|
87
89
|
|
|
88
90
|
<table style="text-align:center;"><tr>
|
|
89
|
-
<td><a href="https://n.inc" target="_blank"><img src="https://nestjs.com/img/n-inc-logo.svg" width="120" valign="middle" /></td
|
|
91
|
+
<td><a href="https://n.inc" target="_blank"><img src="https://nestjs.com/img/n-inc-logo.svg" width="120" valign="middle" /></td>
|
|
92
|
+
<td><a href="https://twistag.com/" target="_blank"><img src="https://nestjs.com/img/twistag-logo.png" width="120" valign="middle" /></td></tr>
|
|
90
93
|
</table>
|
|
91
94
|
|
|
92
95
|
#### Sponsors
|
|
@@ -121,9 +124,9 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
121
124
|
|
|
122
125
|
## Stay in touch
|
|
123
126
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
|
|
128
|
+
- Website - [https://nestjs.com](https://nestjs.com/)
|
|
129
|
+
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
|
127
130
|
|
|
128
131
|
## License
|
|
129
132
|
|
|
@@ -96,6 +96,6 @@ export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDef
|
|
|
96
96
|
private registerUrlencodedContentParser;
|
|
97
97
|
private registerMiddie;
|
|
98
98
|
private getRequestOriginalUrl;
|
|
99
|
-
private
|
|
99
|
+
private injectRouteOptions;
|
|
100
100
|
}
|
|
101
101
|
export {};
|
|
@@ -11,6 +11,7 @@ const symbols_1 = require("fastify/lib/symbols");
|
|
|
11
11
|
const pathToRegexp = require("path-to-regexp");
|
|
12
12
|
// `querystring` is used internally in fastify for registering urlencoded body parser.
|
|
13
13
|
const querystring_1 = require("querystring");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
14
15
|
/**
|
|
15
16
|
* @publicApi
|
|
16
17
|
*/
|
|
@@ -122,25 +123,25 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
122
123
|
return this.instance.listen(options, callback);
|
|
123
124
|
}
|
|
124
125
|
get(...args) {
|
|
125
|
-
return this.
|
|
126
|
+
return this.injectRouteOptions('get', ...args);
|
|
126
127
|
}
|
|
127
128
|
post(...args) {
|
|
128
|
-
return this.
|
|
129
|
+
return this.injectRouteOptions('post', ...args);
|
|
129
130
|
}
|
|
130
131
|
head(...args) {
|
|
131
|
-
return this.
|
|
132
|
+
return this.injectRouteOptions('head', ...args);
|
|
132
133
|
}
|
|
133
134
|
delete(...args) {
|
|
134
|
-
return this.
|
|
135
|
+
return this.injectRouteOptions('delete', ...args);
|
|
135
136
|
}
|
|
136
137
|
put(...args) {
|
|
137
|
-
return this.
|
|
138
|
+
return this.injectRouteOptions('put', ...args);
|
|
138
139
|
}
|
|
139
140
|
patch(...args) {
|
|
140
|
-
return this.
|
|
141
|
+
return this.injectRouteOptions('patch', ...args);
|
|
141
142
|
}
|
|
142
143
|
options(...args) {
|
|
143
|
-
return this.
|
|
144
|
+
return this.injectRouteOptions('options', ...args);
|
|
144
145
|
}
|
|
145
146
|
applyVersionFilter(handler, version, versioningOptions) {
|
|
146
147
|
if (!this.versioningOptions) {
|
|
@@ -353,17 +354,26 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
353
354
|
getRequestOriginalUrl(rawRequest) {
|
|
354
355
|
return rawRequest.originalUrl || rawRequest.url;
|
|
355
356
|
}
|
|
356
|
-
|
|
357
|
+
injectRouteOptions(routerMethodKey, ...args) {
|
|
357
358
|
const handlerRef = args[args.length - 1];
|
|
358
359
|
const isVersioned = !(0, shared_utils_1.isUndefined)(handlerRef.version) &&
|
|
359
360
|
handlerRef.version !== common_1.VERSION_NEUTRAL;
|
|
360
|
-
|
|
361
|
+
const routeConfig = Reflect.getMetadata(constants_1.FASTIFY_ROUTE_CONFIG_METADATA, handlerRef);
|
|
362
|
+
const hasConfig = !(0, shared_utils_1.isUndefined)(routeConfig);
|
|
363
|
+
if (isVersioned || hasConfig) {
|
|
361
364
|
const isPathAndRouteTuple = args.length === 2;
|
|
362
365
|
if (isPathAndRouteTuple) {
|
|
363
366
|
const options = {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
+
...(isVersioned && {
|
|
368
|
+
constraints: {
|
|
369
|
+
version: handlerRef.version,
|
|
370
|
+
},
|
|
371
|
+
}),
|
|
372
|
+
...(hasConfig && {
|
|
373
|
+
config: {
|
|
374
|
+
...routeConfig,
|
|
375
|
+
},
|
|
376
|
+
}),
|
|
367
377
|
};
|
|
368
378
|
const path = args[0];
|
|
369
379
|
return this.instance[routerMethodKey](path, options, handlerRef);
|
package/constants.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FASTIFY_ROUTE_CONFIG_METADATA = "__fastify_route_config__";
|
package/constants.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './route-config.decorator';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouteConfig = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
/**
|
|
7
|
+
* @param config See {@link https://fastify.dev/docs/latest/Reference/Routes/#config}
|
|
8
|
+
*/
|
|
9
|
+
const RouteConfig = (config) => (0, common_1.SetMetadata)(constants_1.FASTIFY_ROUTE_CONFIG_METADATA, config);
|
|
10
|
+
exports.RouteConfig = RouteConfig;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED