fastify 3.11.0 → 3.14.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 +15 -10
- package/SECURITY.md +2 -2
- package/build/build-validation.js +25 -1
- package/docs/Benchmarking.md +3 -3
- package/docs/ContentTypeParser.md +21 -0
- package/docs/Decorators.md +1 -1
- package/docs/Ecosystem.md +38 -26
- package/docs/Encapsulation.md +4 -1
- package/docs/Errors.md +41 -41
- package/docs/Getting-Started.md +2 -2
- package/docs/HTTP2.md +1 -1
- package/docs/Hooks.md +35 -4
- package/docs/LTS.md +1 -1
- package/docs/Lifecycle.md +1 -1
- package/docs/Logging.md +4 -4
- package/docs/Middleware.md +3 -3
- package/docs/Migration-Guide-V3.md +3 -3
- package/docs/Plugins-Guide.md +15 -15
- package/docs/Plugins.md +7 -7
- package/docs/Recommendations.md +3 -4
- package/docs/Reply.md +4 -4
- package/docs/Request.md +1 -1
- package/docs/Routes.md +65 -10
- package/docs/Server.md +80 -14
- package/docs/Serverless.md +43 -64
- package/docs/Style-Guide.md +24 -19
- package/docs/Testing.md +5 -5
- package/docs/TypeScript.md +159 -17
- package/docs/Validation-and-Serialization.md +62 -6
- package/docs/Write-Plugin.md +3 -3
- package/fastify.d.ts +14 -3
- package/fastify.js +52 -18
- package/lib/configValidator.js +288 -53
- package/lib/contentTypeParser.js +28 -7
- package/lib/errors.js +1 -1
- package/lib/pluginOverride.js +5 -5
- package/lib/reply.js +35 -28
- package/lib/reqIdGenFactory.js +2 -1
- package/lib/request.js +1 -1
- package/lib/route.js +20 -27
- package/lib/schema-compilers.js +5 -3
- package/lib/schema-controller.js +106 -0
- package/lib/schemas.js +13 -23
- package/lib/symbols.js +1 -3
- package/lib/warnings.js +4 -0
- package/package.json +22 -17
- package/test/constrained-routes.test.js +184 -0
- package/test/content-parser.test.js +179 -7
- package/test/context-config.test.js +52 -0
- package/test/custom-parser.test.js +262 -2
- package/test/hooks-async.test.js +46 -0
- package/test/hooks.test.js +47 -0
- package/test/internals/initialConfig.test.js +30 -5
- package/test/internals/reply.test.js +2 -2
- package/test/internals/request.test.js +3 -9
- package/test/pretty-print.test.js +28 -0
- package/test/route.test.js +0 -2
- package/test/schema-feature.test.js +134 -4
- package/test/schema-serialization.test.js +42 -0
- package/test/schema-special-usage.test.js +234 -0
- package/test/schema-validation.test.js +1 -1
- package/test/stream.test.js +90 -0
- package/test/throw.test.js +1 -1
- package/test/types/content-type-parser.test-d.ts +8 -2
- package/test/types/fastify.test-d.ts +27 -0
- package/test/types/instance.test-d.ts +43 -1
- package/test/types/logger.test-d.ts +8 -3
- package/test/types/reply.test-d.ts +2 -1
- package/test/types/schema.test-d.ts +52 -1
- package/test/versioned-routes.test.js +99 -18
- package/types/content-type-parser.d.ts +10 -4
- package/types/instance.d.ts +57 -7
- package/types/logger.d.ts +1 -1
- package/types/reply.d.ts +2 -1
- package/types/route.d.ts +15 -11
- package/types/schema.d.ts +5 -4
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="https://github.com/fastify/graphics/raw/
|
|
2
|
+
<img src="https://github.com/fastify/graphics/raw/HEAD/full-logo.png" width="650" height="auto"/>
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
6
6
|
|
|
7
|
-

|
|
8
|
-

|
|
9
|
-

|
|
7
|
+
[](https://github.com/fastify/fastify/actions/workflows/ci.yml)
|
|
8
|
+
[](https://github.com/fastify/fastify/actions/workflows/package-manager-ci.yml)
|
|
9
|
+
[](https://github.com/fastify/fastify/actions/workflows/website.yml)
|
|
10
10
|
[](https://snyk.io/test/github/fastify/fastify)
|
|
11
|
-
[](https://coveralls.io/github/fastify/fastify?branch=main)
|
|
12
12
|
[](https://standardjs.com/)
|
|
13
13
|
|
|
14
14
|
</div>
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
[](https://www.npmjs.com/package/fastify)
|
|
19
19
|
[](https://www.npmjs.com/package/fastify)
|
|
20
20
|
[](https://github.com/nodejs/security-wg/blob/
|
|
22
|
-
[](https://discord.gg/
|
|
21
|
+
Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/nodejs/security-wg/blob/HEAD/processes/responsible_disclosure_template.md)
|
|
22
|
+
[](https://discord.gg/fastify)
|
|
23
23
|
|
|
24
24
|
</div>
|
|
25
25
|
|
|
@@ -191,7 +191,7 @@ matters to you.
|
|
|
191
191
|
* <a href="./docs/Serverless.md"><code><b>Serverless</b></code></a>
|
|
192
192
|
* <a href="./docs/Recommendations.md"><code><b>Recommendations</b></code></a>
|
|
193
193
|
|
|
194
|
-
中文文档[地址](https://github.com/fastify/docs-chinese/blob/
|
|
194
|
+
中文文档[地址](https://github.com/fastify/docs-chinese/blob/HEAD/README.md)
|
|
195
195
|
|
|
196
196
|
## Ecosystem
|
|
197
197
|
|
|
@@ -216,10 +216,12 @@ Team members are listed in alphabetical order.
|
|
|
216
216
|
### Fastify Core team
|
|
217
217
|
* [__Tommaso Allevi__](https://github.com/allevo), <https://twitter.com/allevitommaso>, <https://www.npmjs.com/~allevo>
|
|
218
218
|
* [__Ethan Arrowood__](https://github.com/Ethan-Arrowood/), <https://twitter.com/arrowoodtech>, <https://www.npmjs.com/~ethan_arrowood>
|
|
219
|
+
* [__Harry Brundage__](https://github.com/airhorns/), <https://twitter.com/harrybrundage>, <https://www.npmjs.com/~airhorns>
|
|
219
220
|
* [__David Mark Clements__](https://github.com/davidmarkclements), <https://twitter.com/davidmarkclem>, <https://www.npmjs.com/~davidmarkclements>
|
|
220
221
|
* [__Matteo Collina__](https://github.com/mcollina), <https://twitter.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>
|
|
221
222
|
* [__Tomas Della Vedova__](https://github.com/delvedor), <https://twitter.com/delvedor>, <https://www.npmjs.com/~delvedor>
|
|
222
223
|
* [__Dustin Deus__](https://github.com/StarpTech), <https://twitter.com/dustindeus>, <https://www.npmjs.com/~starptech>
|
|
224
|
+
* [__Ayoub El Khattabi__](https://github.com/AyoubElk), <https://twitter.com/ayoubelkh>, <https://www.npmjs.com/~ayoubelk>
|
|
223
225
|
* [__Denis Fäcke__](https://github.com/SerayaEryn), <https://twitter.com/serayaeryn>, <https://www.npmjs.com/~serayaeryn>
|
|
224
226
|
* [__Rafael Gonzaga__](https://github.com/rafaelgss), <https://twitter.com/_rafaelgss>, <https://www.npmjs.com/~rafaelgss>
|
|
225
227
|
* [__Vincent Le Goff__](https://github.com/zekth)
|
|
@@ -230,10 +232,13 @@ Team members are listed in alphabetical order.
|
|
|
230
232
|
|
|
231
233
|
### Fastify Plugins team
|
|
232
234
|
* [__Matteo Collina__](https://github.com/mcollina), <https://twitter.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>
|
|
235
|
+
* [__Harry Brundage__](https://github.com/airhorns/), <https://twitter.com/harrybrundage>, <https://www.npmjs.com/~airhorns>
|
|
233
236
|
* [__Tomas Della Vedova__](https://github.com/delvedor), <https://twitter.com/delvedor>, <https://www.npmjs.com/~delvedor>
|
|
237
|
+
* [__Ayoub El Khattabi__](https://github.com/AyoubElk), <https://twitter.com/ayoubelkh>, <https://www.npmjs.com/~ayoubelk>
|
|
234
238
|
* [__Vincent Le Goff__](https://github.com/zekth)
|
|
235
239
|
* [__Salman Mitha__](https://github.com/salmanm), <https://www.npmjs.com/~salmanm>
|
|
236
240
|
* [__Maksim Sinik__](https://github.com/fox1t), <https://twitter.com/maksimsinik>, <https://www.npmjs.com/~fox1t>
|
|
241
|
+
* [__Frazer Smith__](https://github.com/Fdawgs), <https://www.npmjs.com/~fdawgs>
|
|
237
242
|
* [__Manuel Spigolon__](https://github.com/eomm), <https://twitter.com/manueomm>, <https://www.npmjs.com/~eomm>
|
|
238
243
|
|
|
239
244
|
### Great Contributors
|
|
@@ -251,9 +256,9 @@ Great contributors on a specific area in the Fastify ecosystem will be invited t
|
|
|
251
256
|
|
|
252
257
|
## Hosted by
|
|
253
258
|
|
|
254
|
-
[<img src="https://github.com/openjs-foundation/cross-project-council/blob/
|
|
259
|
+
[<img src="https://github.com/openjs-foundation/cross-project-council/blob/HEAD/logos/openjsf-color.png?raw=true" width="250px;"/>](https://openjsf.org/projects/#growth)
|
|
255
260
|
|
|
256
|
-
We are a [Growth Project](https://github.com/openjs-foundation/cross-project-council/blob/
|
|
261
|
+
We are a [Growth Project](https://github.com/openjs-foundation/cross-project-council/blob/HEAD/PROJECT_PROGRESSION.md#growth-stage) in the [OpenJS Foundation](https://openjsf.org/).
|
|
257
262
|
|
|
258
263
|
## Acknowledgements
|
|
259
264
|
|
package/SECURITY.md
CHANGED
|
@@ -9,7 +9,7 @@ Individuals who find potential vulnerabilities in Fastify are invited to complet
|
|
|
9
9
|
|
|
10
10
|
### How to report a vulnerability
|
|
11
11
|
|
|
12
|
-
It is of the utmost importance that you read carefully [**HOW TO REPORT A VULNERABILITY**](https://github.com/nodejs/security-wg/blob/
|
|
12
|
+
It is of the utmost importance that you read carefully [**HOW TO REPORT A VULNERABILITY**](https://github.com/nodejs/security-wg/blob/HEAD/processes/third_party_vuln_process.md) written by the Security Working Group of Node.js.
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
## Handling vulnerability reports
|
|
@@ -24,7 +24,7 @@ When a potential vulnerability is reported and confirmed the Fastify Core Team w
|
|
|
24
24
|
|
|
25
25
|
## The Fastify Core team
|
|
26
26
|
|
|
27
|
-
The core team is responsible for the management of [this](https://github.com/nodejs/security-wg/blob/
|
|
27
|
+
The core team is responsible for the management of [this](https://github.com/nodejs/security-wg/blob/HEAD/processes/third_party_vuln_process.md#handling-vulnerability-reports) process.
|
|
28
28
|
|
|
29
29
|
Members of this team are expected to keep all information that they have privileged access to by being
|
|
30
30
|
on the team completely private to the team. This includes agreeing to not notify anyone outside the
|
|
@@ -79,7 +79,31 @@ const schema = {
|
|
|
79
79
|
pluginTimeout: { type: 'integer', default: defaultInitOptions.pluginTimeout },
|
|
80
80
|
requestIdHeader: { type: 'string', default: defaultInitOptions.requestIdHeader },
|
|
81
81
|
requestIdLogLabel: { type: 'string', default: defaultInitOptions.requestIdLogLabel },
|
|
82
|
-
http2SessionTimeout: { type: 'integer', default: defaultInitOptions.http2SessionTimeout }
|
|
82
|
+
http2SessionTimeout: { type: 'integer', default: defaultInitOptions.http2SessionTimeout },
|
|
83
|
+
// deprecated style of passing the versioning constraint
|
|
84
|
+
versioning: {
|
|
85
|
+
type: 'object',
|
|
86
|
+
additionalProperties: true,
|
|
87
|
+
required: ['storage', 'deriveVersion'],
|
|
88
|
+
properties: {
|
|
89
|
+
storage: { },
|
|
90
|
+
deriveVersion: { }
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
constraints: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
additionalProperties: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
required: ['name', 'storage', 'validate', 'deriveConstraint'],
|
|
98
|
+
additionalProperties: true,
|
|
99
|
+
properties: {
|
|
100
|
+
name: { type: 'string' },
|
|
101
|
+
storage: { },
|
|
102
|
+
validate: { },
|
|
103
|
+
deriveConstraint: { }
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
83
107
|
}
|
|
84
108
|
}
|
|
85
109
|
|
package/docs/Benchmarking.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<h1 align="center">Fastify</h1>
|
|
2
2
|
|
|
3
3
|
## Benchmarking
|
|
4
|
-
Benchmarking is important if you want to measure how a change can
|
|
4
|
+
Benchmarking is important if you want to measure how a change can affect the performance of your application. We provide a simple way to benchmark your application from the point of view of a user and contributor. The setup allows you to automate benchmarks in different branches and on different Node.js versions.
|
|
5
5
|
|
|
6
6
|
The modules we'll use:
|
|
7
7
|
- [Autocannon](https://github.com/mcollina/autocannon): A HTTP/1.1 benchmarking tool written in node.
|
|
8
8
|
- [Branch-comparer](https://github.com/StarpTech/branch-comparer): Checkout multiple git branches, execute scripts and log the results.
|
|
9
9
|
- [Concurrently](https://github.com/kimmobrunfeldt/concurrently): Run commands concurrently.
|
|
10
|
-
- [Npx](https://github.com/
|
|
10
|
+
- [Npx](https://github.com/npm/npx): NPM package runner used to run scripts against different Node.js Versions and to execute local binaries. Shipped with npm@5.2.0.
|
|
11
11
|
|
|
12
12
|
## Simple
|
|
13
13
|
|
|
@@ -33,7 +33,7 @@ branchcmp --rounds 2 --script "npm run benchmark"
|
|
|
33
33
|
branchcmp --rounds 2 --script "npm run benchmark"
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
### Compare current branch with
|
|
36
|
+
### Compare current branch with main (Gitflow)
|
|
37
37
|
```sh
|
|
38
38
|
branchcmp --rounds 2 --gitflow --script "npm run benchmark"
|
|
39
39
|
```
|
|
@@ -29,10 +29,31 @@ fastify.addContentTypeParser('application/jsoff', async function (request, paylo
|
|
|
29
29
|
return res
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
+
// Handle all content types that matches RegExp
|
|
33
|
+
fastify.addContentTypeParser(/^image\/.*/, function (request, payload, done) {
|
|
34
|
+
imageParser(payload, function (err, body) {
|
|
35
|
+
done(err, body)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
32
39
|
// Can use default JSON/Text parser for different content Types
|
|
33
40
|
fastify.addContentTypeParser('text/json', { parseAs: 'string' }, fastify.getDefaultJsonParser('ignore', 'ignore'))
|
|
34
41
|
```
|
|
35
42
|
|
|
43
|
+
Fastify first tries to match a content-type parser with a `string` value before trying to find a matching `RegExp`.
|
|
44
|
+
If you provide overlapping content types, Fastify tries to find a matching content type by starting with the last one passed and ending with the first one.
|
|
45
|
+
So if you want to specify a general content type more precisely, first specify the general content type and then the more specific one, like in the example below.
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
// Here only the second content type parser is called because its value also matches the first one
|
|
49
|
+
fastify.addContentTypeParser('application/vnd.custom+xml', (request, body, done) => {} )
|
|
50
|
+
fastify.addContentTypeParser('application/vnd.custom', (request, body, done) => {} )
|
|
51
|
+
|
|
52
|
+
// Here the desired behavior is achieved because fastify first tries to match the `application/vnd.custom+xml` content type parser
|
|
53
|
+
fastify.addContentTypeParser('application/vnd.custom', (request, body, done) => {} )
|
|
54
|
+
fastify.addContentTypeParser('application/vnd.custom+xml', (request, body, done) => {} )
|
|
55
|
+
```
|
|
56
|
+
|
|
36
57
|
You can also use the `hasContentTypeParser` API to find if a specific content type parser already exists.
|
|
37
58
|
|
|
38
59
|
```js
|
package/docs/Decorators.md
CHANGED
package/docs/Ecosystem.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Ecosystem
|
|
4
4
|
|
|
5
|
-
Plugins maintained by the
|
|
5
|
+
Plugins maintained by the Fastify team are listed under [Core](#core) while plugins maintained by the community are listed in the [Community](#community) section.
|
|
6
6
|
|
|
7
7
|
#### [Core](#core)
|
|
8
8
|
|
|
@@ -10,19 +10,20 @@ Plugins maintained by the fastify team are listed under [Core](#core) while plug
|
|
|
10
10
|
- [`fastify-accepts-serializer`](https://github.com/fastify/fastify-accepts-serializer) to serialize to output according to `Accept` header.
|
|
11
11
|
- [`fastify-auth`](https://github.com/fastify/fastify-auth) Run multiple auth functions in Fastify.
|
|
12
12
|
- [`fastify-autoload`](https://github.com/fastify/fastify-autoload) Require all plugins in a directory.
|
|
13
|
-
- [`fastify-awilix`](https://github.com/fastify/fastify-awilix) Dependency injection support for
|
|
13
|
+
- [`fastify-awilix`](https://github.com/fastify/fastify-awilix) Dependency injection support for Fastify, based on [awilix](https://github.com/jeffijoe/awilix).
|
|
14
14
|
- [`fastify-bankai`](https://github.com/fastify/fastify-bankai) [Bankai](https://github.com/yoshuawuyts/bankai) assets compiler for Fastify.
|
|
15
15
|
- [`fastify-basic-auth`](https://github.com/fastify/fastify-basic-auth) Basic auth plugin for Fastify.
|
|
16
16
|
- [`fastify-bearer-auth`](https://github.com/fastify/fastify-bearer-auth) Bearer auth plugin for Fastify.
|
|
17
|
-
- [`fastify-caching`](https://github.com/fastify/fastify-caching) General server-side cache and
|
|
17
|
+
- [`fastify-caching`](https://github.com/fastify/fastify-caching) General server-side cache and ETag support.
|
|
18
18
|
- [`fastify-circuit-breaker`](https://github.com/fastify/fastify-circuit-breaker) A low overhead circuit breaker for your routes.
|
|
19
19
|
- [`fastify-compress`](https://github.com/fastify/fastify-compress) Fastify compression utils.
|
|
20
20
|
- [`fastify-cookie`](https://github.com/fastify/fastify-cookie) Parse and set cookie headers.
|
|
21
21
|
- [`fastify-cors`](https://github.com/fastify/fastify-cors) Enables the use of CORS in a Fastify application.
|
|
22
22
|
- [`fastify-csrf`](https://github.com/fastify/fastify-csrf) A plugin for adding [CSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery) protection to Fastify.
|
|
23
|
+
- [`fastify-diagnostics-channel`](https://github.com/fastify/fastify-diagnostics-channel) Plugin to deal with `diagnostics_channel` on Fastify
|
|
23
24
|
- [`fastify-elasticsearch`](https://github.com/fastify/fastify-elasticsearch) Plugin to share the same ES client.
|
|
24
25
|
- [`fastify-env`](https://github.com/fastify/fastify-env) Load and check configuration.
|
|
25
|
-
- [`fastify-etag`](https://github.com/fastify/fastify-etag) Automatically generate
|
|
26
|
+
- [`fastify-etag`](https://github.com/fastify/fastify-etag) Automatically generate ETags for HTTP responses.
|
|
26
27
|
- [`fastify-flash`](https://github.com/fastify/fastify-flash) Set and get flash messages using the session.
|
|
27
28
|
- [`fastify-formbody`](https://github.com/fastify/fastify-formbody) Plugin to parse x-www-form-urlencoded bodies.
|
|
28
29
|
- [`fastify-funky`](https://github.com/fastify/fastify-funky) Makes functional programming in Fastify more convenient. Adds support for Fastify routes returning functional structures, such as Either, Task or plain parameterless function.
|
|
@@ -44,7 +45,7 @@ Plugins maintained by the fastify team are listed under [Core](#core) while plug
|
|
|
44
45
|
- [`fastify-schedule`](https://github.com/fastify/fastify-schedule) Plugin for scheduling periodic jobs, based on [toad-scheduler](https://github.com/kibertoad/toad-scheduler).
|
|
45
46
|
- [`fastify-sensible`](https://github.com/fastify/fastify-sensible) Defaults for Fastify that everyone can agree on. It adds some useful decorators such as http errors and assertions, but also more request and reply methods.
|
|
46
47
|
- [`fastify-static`](https://github.com/fastify/fastify-static) Plugin for serving static files as fast as possible.
|
|
47
|
-
- [`fastify-swagger`](https://github.com/fastify/fastify-swagger) Swagger documentation
|
|
48
|
+
- [`fastify-swagger`](https://github.com/fastify/fastify-swagger) Plugin for serving Swagger/OpenAPI documentation for Fastify, supporting dynamic generation.
|
|
48
49
|
- [`fastify-websocket`](https://github.com/fastify/fastify-websocket) WebSocket support for Fastify. Built upon [websocket-stream](https://github.com/maxogden/websocket-stream).
|
|
49
50
|
- [`fastify-url-data`](https://github.com/fastify/fastify-url-data) Decorate the `Request` object with a method to access raw URL components.
|
|
50
51
|
- [`point-of-view`](https://github.com/fastify/point-of-view) Templates rendering (_ejs, pug, handlebars, marko_) plugin support for Fastify.
|
|
@@ -52,16 +53,25 @@ Plugins maintained by the fastify team are listed under [Core](#core) while plug
|
|
|
52
53
|
|
|
53
54
|
#### [Community](#community)
|
|
54
55
|
|
|
56
|
+
- [`@coobaha/typed-fastify`](https://github.com/Coobaha/typed-fastify) Strongly typed routes with a runtime validation using JSON schema generated from types.
|
|
55
57
|
- [`@dnlup/fastify-doc`](https://github.com/dnlup/fastify-doc) A plugin for sampling process metrics.
|
|
56
58
|
- [`@dnlup/fastify-traps`](https://github.com/dnlup/fastify-traps) A plugin to close the server gracefully on `SIGINT` and `SIGTERM` signals.
|
|
59
|
+
- [`@gquittet/graceful-server`](https://github.com/gquittet/graceful-server) Tiny (~5k), Fast, KISS and dependency-free Node.JS library to make your Fastify API graceful.
|
|
60
|
+
- [`@mgcrea/fastify-graceful-exit`](https://github.com/mgcrea/fastify-graceful-exit) A plugin to close the server gracefully
|
|
61
|
+
- [`@mgcrea/fastify-request-logger`](https://github.com/mgcrea/fastify-request-logger) A plugin to enable compact request logging for fastify
|
|
62
|
+
- [`@mgcrea/fastify-session-redis-store`](https://github.com/mgcrea/fastify-session-redis-store) Redis store for @mgcrea/fastify-session using ioredis
|
|
63
|
+
- [`@mgcrea/fastify-session-sodium-crypto`](https://github.com/mgcrea/fastify-session-sodium-crypto) Fast sodium-based crypto for @mgcrea/fastify-session
|
|
64
|
+
- [`@mgcrea/fastify-session`](https://github.com/mgcrea/fastify-session) Session plugin for fastify that supports both stateless and sateful sessions
|
|
65
|
+
- [`@mgcrea/pino-pretty-compact`](https://github.com/mgcrea/pino-pretty-compact) A custom compact pino-base prettifier
|
|
57
66
|
- [`apollo-server-fastify`](https://github.com/apollographql/apollo-server/tree/master/packages/apollo-server-fastify) Run an [Apollo Server](https://github.com/apollographql/apollo-server) to serve GraphQL with Fastify.
|
|
58
67
|
- [`arecibo`](https://github.com/nucleode/arecibo) Fastify ping responder for Kubernetes Liveness and Readiness Probes.
|
|
59
68
|
- [`cls-rtracer`](https://github.com/puzpuzpuz/cls-rtracer) Fastify middleware for CLS-based request id generation. An out-of-the-box solution for adding request ids into your logs.
|
|
60
69
|
- [`fastify-405`](https://github.com/Eomm/fastify-405) Fastify plugin that adds 405 HTTP status to your routes
|
|
61
70
|
- [`fastify-amqp`](https://github.com/RafaelGSS/fastify-amqp) Fastify AMQP connection plugin, to use with RabbitMQ or another connector. Just a wrapper to [`amqplib`](https://github.com/squaremo/amqp.node).
|
|
62
71
|
- [`fastify-angular-universal`](https://github.com/exequiel09/fastify-angular-universal) Angular server-side rendering support using [`@angular/platform-server`](https://github.com/angular/angular/tree/master/packages/platform-server) for Fastify
|
|
72
|
+
- [`fastify-api-key`](https://github.com/arkerone/fastify-api-key) Fastify plugin to authenticate HTTP requests based on api key and signature
|
|
63
73
|
- [`fastify-auth0-verify`](https://github.com/nearform/fastify-auth0-verify): Auth0 verification plugin for Fastify, internally uses [fastify-jwt](https://npm.im/fastify-jwt) and [jsonwebtoken](https://npm.im/jsonwebtoken).
|
|
64
|
-
- [`fastify-autocrud`](https://github.com/paranoiasystem/fastify-autocrud) Plugin
|
|
74
|
+
- [`fastify-autocrud`](https://github.com/paranoiasystem/fastify-autocrud) Plugin to autogenerate CRUD routes as fast as possible.
|
|
65
75
|
- [`fastify-autoroutes`](https://github.com/GiovanniCardamone/fastify-autoroutes) Plugin to scan and load routes based on filesystem path from custom directory.
|
|
66
76
|
- [`fastify-axios`](https://github.com/davidedantonio/fastify-axios) Plugin to send HTTP requests via [axios](https://github.com/axios/axios).
|
|
67
77
|
- [`fastify-babel`](https://github.com/cfware/fastify-babel) Fastify plugin for development servers which require babel transformations of JavaScript sources.
|
|
@@ -81,8 +91,8 @@ Plugins maintained by the fastify team are listed under [Core](#core) while plug
|
|
|
81
91
|
- [`fastify-dynareg`](https://github.com/greguz/fastify-dynareg) Dynamic plugin register for Fastify.
|
|
82
92
|
- [`fastify-envalid`](https://github.com/alemagio/fastify-envalid) Fastify plugin to integrate [envalid](https://github.com/af/envalid) in your Fastify project.
|
|
83
93
|
- [`fastify-error-page`](https://github.com/hemerajs/fastify-error-page) Fastify plugin to print errors in structured HTML to the browser.
|
|
84
|
-
- [`fastify-
|
|
85
|
-
- [`fastify-
|
|
94
|
+
- [`fastify-esso`](https://github.com/patrickpissurno/fastify-esso) The easiest authentication plugin for Fastify, with built-in support for Single sign-on (and great documentation).
|
|
95
|
+
- [`fastify-explorer`](https://github.com/Eomm/fastify-explorer) Get control of your decorators across all the encapsulated contexts.
|
|
86
96
|
- [`fastify-favicon`](https://github.com/smartiniOnGitHub/fastify-favicon) Fastify plugin to serve default favicon.
|
|
87
97
|
- [`fastify-feature-flags`](https://gitlab.com/m03geek/fastify-feature-flags) Fastify feature flags plugin with multiple providers support (e.g. env, [config](https://lorenwest.github.io/node-config/), [unleash](https://unleash.github.io/)).
|
|
88
98
|
- [`fastify-file-upload`](https://github.com/huangang/fastify-file-upload) Fastify plugin for uploading files.
|
|
@@ -92,23 +102,23 @@ Plugins maintained by the fastify team are listed under [Core](#core) while plug
|
|
|
92
102
|
- [`fastify-get-head`](https://github.com/MetCoder95/fastify-get-head) Small plugin to set a new HEAD route handler for each GET route previously registered in Fastify.
|
|
93
103
|
- [`fastify-google-cloud-storage`](https://github.com/carlozamagni/fastify-google-cloud-storage) Fastify plugin that exposes a GCP Cloud Storage client instance.
|
|
94
104
|
- [`fastify-grant`](https://github.com/simov/fastify-grant) Authentication/Authorization plugin for Fastify that supports 200+ OAuth Providers.
|
|
95
|
-
- [`fastify-guard`](https://github.com/hsynlms/fastify-guard) A
|
|
105
|
+
- [`fastify-guard`](https://github.com/hsynlms/fastify-guard) A Fastify plugin that protects endpoints by checking authenticated user roles and/or scopes.
|
|
96
106
|
- [`fastify-graceful-shutdown`](https://github.com/hemerajs/fastify-graceful-shutdown) Shutdown Fastify gracefully and asynchronously.
|
|
97
107
|
- [`fastify-healthcheck`](https://github.com/smartiniOnGitHub/fastify-healthcheck) Fastify plugin to serve an health check route and a probe script.
|
|
98
108
|
- [`fastify-hemera`](https://github.com/hemerajs/fastify-hemera) Fastify Hemera plugin, for writing reliable & fault-tolerant microservices with [nats.io](https://nats.io/).
|
|
109
|
+
- [`fastify-http-context`](https://github.com/thorough-developer/fastify-http-context) Fastify plugin for "simulating" a thread of execution to allow for true http context to take place per API call within the Fastify lifecycle of calls.
|
|
99
110
|
- [`fastify-http2https`](https://github.com/lolo32/fastify-http2https) Redirect HTTP requests to HTTPS, both using the same port number, or different response on HTTP and HTTPS.
|
|
100
|
-
- [`fastify-http-context`](https://github.com/thorough-developer/fastify-http-context) Fastify plugin for "simulating" a thread of execution to allow for true http context to take place per api call within the fastify lifecycle of calls.
|
|
101
|
-
- [`fastify-https-redirect`](https://github.com/tomsvogel/fastify-https-redirect) Fastify plugin for auto redirect from http to https
|
|
102
111
|
- [`fastify-http-client`](https://github.com/kenuyx/fastify-http-client) Plugin to send HTTP(s) requests. Built upon [urllib](https://github.com/node-modules/urllib).
|
|
103
112
|
- [`fastify-http-errors-enhanced`](https://github.com/ShogunPanda/fastify-http-errors-enhanced) An error handling plugin for Fastify that uses enhanced HTTP errors.
|
|
113
|
+
- [`fastify-https-redirect`](https://github.com/tomsvogel/fastify-https-redirect) Fastify plugin for auto redirect from http to https.
|
|
104
114
|
- [`fastify-influxdb`](https://github.com/alex-ppg/fastify-influxdb) Fastify InfluxDB plugin connecting to an InfluxDB instance via the Influx default package.
|
|
105
115
|
- [`fastify-jwt-authz`](https://github.com/Ethan-Arrowood/fastify-jwt-authz) JWT user scope verifier.
|
|
106
|
-
- [`fastify-jwt-webapp`](https://github.com/charlesread/fastify-jwt-webapp) JWT authentication for
|
|
116
|
+
- [`fastify-jwt-webapp`](https://github.com/charlesread/fastify-jwt-webapp) JWT authentication for Fastify-based web apps.
|
|
107
117
|
- [`fastify-knexjs`](https://github.com/chapuletta/fastify-knexjs) Fastify plugin for support KnexJS Query Builder.
|
|
108
118
|
- [`fastify-knexjs-mock`](https://github.com/chapuletta/fastify-knexjs-mock) Fastify Mock KnexJS for testing support.
|
|
109
119
|
- [`fastify-kubernetes`](https://github.com/greguz/fastify-kubernetes) Fastify Kubernetes client plugin.
|
|
110
120
|
- [`fastify-language-parser`](https://github.com/lependu/fastify-language-parser) Fastify plugin to parse request language.
|
|
111
|
-
- [`fastify-loader`](https://github.com/TheNoim/fastify-loader) Load routes from a directory and inject the
|
|
121
|
+
- [`fastify-loader`](https://github.com/TheNoim/fastify-loader) Load routes from a directory and inject the Fastify instance in each file.
|
|
112
122
|
- [`fastify-lured`](https://github.com/lependu/fastify-lured) Plugin to load lua scripts with [fastify-redis](https://github.com/fastify/fastify-redis) and [lured](https://github.com/enobufs/lured).
|
|
113
123
|
- [`fastify-markdown`](https://github.com/freezestudio/fastify-markdown) Plugin to markdown support.
|
|
114
124
|
- [`fastify-method-override`](https://github.com/corsicanec82/fastify-method-override) Plugin for Fastify, which allows use HTTP verbs, such as DELETE, PATCH, HEAD, PUT, OPTIONS in case the client doesn't support them.
|
|
@@ -123,20 +133,21 @@ Plugins maintained by the fastify team are listed under [Core](#core) while plug
|
|
|
123
133
|
- [`fastify-no-icon`](https://github.com/jsumners/fastify-no-icon) Plugin to eliminate thrown errors for `/favicon.ico` requests.
|
|
124
134
|
- [`fastify-nodemailer`](https://github.com/lependu/fastify-nodemailer) Plugin to share [nodemailer](https://nodemailer.com) transporter across Fastify.
|
|
125
135
|
- [`fastify-normalize-request-reply`](https://github.com/ericrglass/fastify-normalize-request-reply) Plugin to normalize the request and reply to the Express version 4.x request and response, which allows use of middleware, like swagger-stats, that was originally written for Express.
|
|
126
|
-
- [`fastify-now`](https://github.com/yonathan06/fastify-now) Structure your endpoints in a folder and load them dynamically with
|
|
136
|
+
- [`fastify-now`](https://github.com/yonathan06/fastify-now) Structure your endpoints in a folder and load them dynamically with Fastify.
|
|
137
|
+
- [`fastify-nuxtjs`](https://github.com/gomah/fastify-nuxtjs) Vue server side rendering support for Fastify with Nuxt.js Framework.
|
|
127
138
|
- [`fastify-oas`](https://gitlab.com/m03geek/fastify-oas) Generates OpenAPI 3.0+ documentation from routes schemas for Fastify.
|
|
128
139
|
- [`fastify-objectionjs`](https://github.com/jarcodallo/fastify-objectionjs) Plugin for the `fastify` framework that provides integration with objectionjs ORM.
|
|
129
140
|
- [`fastify-objectionjs-classes`](https://github.com/kamikazechaser/fastify-objectionjs-classes) Plugin to cherry pick classes from objectionjs ORM.
|
|
130
|
-
- [`fastify-openapi-docs`](https://github.com/ShogunPanda/fastify-openapi-docs) A
|
|
131
|
-
- [`fastify-openapi-glue`](https://github.com/seriousme/fastify-openapi-glue) Glue for
|
|
141
|
+
- [`fastify-openapi-docs`](https://github.com/ShogunPanda/fastify-openapi-docs) A Fastify plugin that generates OpenAPI spec automatically.
|
|
142
|
+
- [`fastify-openapi-glue`](https://github.com/seriousme/fastify-openapi-glue) Glue for OpenAPI specifications in Fastify, autogenerates routes based on an OpenAPI Specification.
|
|
132
143
|
- [`fastify-opentelemetry`](https://github.com/autotelic/fastify-opentelemetry) A Fastify plugin that uses the [OpenTelemetry API](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-api) to provide request tracing.
|
|
133
144
|
- [`fastify-oracle`](https://github.com/cemremengu/fastify-oracle) Attaches an [`oracledb`](https://github.com/oracle/node-oracledb) connection pool to a Fastify server instance.
|
|
134
145
|
- [`fastify-orientdb`](https://github.com/mahmed8003/fastify-orientdb) Fastify OrientDB connection plugin, with which you can share the OrientDB connection across every part of your server.
|
|
135
146
|
- [`fastify-piscina`](https://github.com/piscinajs/fastify-piscina) A worker thread pool plugin using [Piscina](https://github.com/piscinajs/piscina).
|
|
136
147
|
- [`fastify-peekaboo`](https://github.com/simone-sanfratello/fastify-peekaboo) Fastify plugin for memoize responses by expressive settings.
|
|
137
148
|
- [`fastify-postgraphile`](https://github.com/alemagio/fastify-postgraphile) Plugin to integrate [PostGraphile](https://www.graphile.org/postgraphile/) in a Fastify project.
|
|
138
|
-
- [`fastify-prettier`](https://github.com/hsynlms/fastify-prettier) A
|
|
139
|
-
- [`fastify-print-routes`](https://github.com/ShogunPanda/fastify-print-routes) A
|
|
149
|
+
- [`fastify-prettier`](https://github.com/hsynlms/fastify-prettier) A Fastify plugin that uses [prettier](https://github.com/prettier/prettier) under the hood to beautify outgoing responses and/or other things in the Fastify server.
|
|
150
|
+
- [`fastify-print-routes`](https://github.com/ShogunPanda/fastify-print-routes) A Fastify plugin that prints all available routes.
|
|
140
151
|
- [`fastify-qrcode`](https://github.com/chonla/fastify-qrcode) This plugin utilizes [qrcode](https://github.com/soldair/node-qrcode) to generate QR Code.
|
|
141
152
|
- [`fastify-qs`](https://github.com/webdevium/fastify-qs) A plugin for Fastify that adds support for parsing URL query parameters with [qs](https://github.com/ljharb/qs).
|
|
142
153
|
- [`fastify-raw-body`](https://github.com/Eomm/fastify-raw-body) Add the `request.rawBody` field.
|
|
@@ -149,7 +160,8 @@ Plugins maintained by the fastify team are listed under [Core](#core) while plug
|
|
|
149
160
|
- [`fastify-reverse-routes`](https://github.com/dimonnwc3/fastify-reverse-routes) Fastify reverse routes plugin, allows to defined named routes and build path using name and parameters.
|
|
150
161
|
- [`fastify-rob-config`](https://github.com/jeromemacias/fastify-rob-config) Fastify Rob-Config integration.
|
|
151
162
|
- [`fastify-schema-constraint`](https://github.com/Eomm/fastify-schema-constraint) Choose the JSON schema to use based on request parameters.
|
|
152
|
-
- [`fastify-
|
|
163
|
+
- [`fastify-schema-to-typescript`](https://github.com/thomasthiebaud/fastify-schema-to-typescript) Generate typescript types based on your json/yaml validation schemas so they are always in sync.
|
|
164
|
+
- [`fastify-secure-session`](https://github.com/mcollina/fastify-secure-session) Create a secure stateless cookie session for Fastify.
|
|
153
165
|
- [`fastify-sentry`](https://github.com/alex-ppg/fastify-sentry) Fastify plugin to add the Sentry SDK error handler to requests.
|
|
154
166
|
- [`fastify-sequelize`](https://github.com/lyquocnam/fastify-sequelize) Fastify plugin work with Sequelize (adapter for NodeJS -> Sqlite, Mysql, Mssql, Postgres).
|
|
155
167
|
- [`fastify-server-session`](https://github.com/jsumners/fastify-server-session) A session plugin with support for arbitrary backing caches via `fastify-caching`.
|
|
@@ -160,18 +172,18 @@ Plugins maintained by the fastify team are listed under [Core](#core) while plug
|
|
|
160
172
|
- [`fastify-sse-v2`](https://github.com/nodefactoryio/fastify-sse-v2) to provide Server-Sent Events using Async Iterators (supports newer versions of Fastify).
|
|
161
173
|
- [`fastify-tls-keygen`](https://gitlab.com/sebdeckers/fastify-tls-keygen) Automatically generate a browser-compatible, trusted, self-signed, localhost-only, TLS certificate.
|
|
162
174
|
- [`fastify-tokenize`](https://github.com/Bowser65/fastify-tokenize) [Tokenize](https://github.com/Bowser65/Tokenize) plugin for Fastify that removes the pain of managing authentication tokens, with built-in integration for `fastify-auth`.
|
|
163
|
-
- [`fastify-totp`](https://github.com/heply/fastify-totp) A plugin to handle TOTP (e.g. for 2FA)
|
|
175
|
+
- [`fastify-totp`](https://github.com/heply/fastify-totp) A plugin to handle TOTP (e.g. for 2FA).
|
|
164
176
|
- [`fastify-twitch-ebs-tools`](https://github.com/lukemnet/fastify-twitch-ebs-tools) Useful functions for Twitch Extension Backend Services (EBS).
|
|
165
177
|
- [`fastify-typeorm-plugin`](https://github.com/inthepocket/fastify-typeorm-plugin) Fastify plugin to work with TypeORM.
|
|
166
178
|
- [`fastify-vhost`](https://github.com/patrickpissurno/fastify-vhost) Proxy subdomain http requests to another server (useful if you want to point multiple subdomains to the same IP address, while running different servers on the same machine).
|
|
167
|
-
- [`fastify-
|
|
168
|
-
- [`fastify-vue-plugin`](https://github.com/TheNoim/fastify-vue) [Nuxt.js](https://nuxtjs.org) plugin for
|
|
169
|
-
- [`fastify-wamp-router`](https://github.com/lependu/fastify-wamp-router) Web Application Messaging Protocol router for
|
|
170
|
-
- [`fast-water`](https://github.com/tswayne/fast-water) A
|
|
179
|
+
- [`fastify-vite`](https://github.com/galvez/fastify-vite) [Vite](https://vitejs.dev/) plugin for Fastify with SSR data support.
|
|
180
|
+
- [`fastify-vue-plugin`](https://github.com/TheNoim/fastify-vue) [Nuxt.js](https://nuxtjs.org) plugin for Fastify. Control the routes nuxt should use.
|
|
181
|
+
- [`fastify-wamp-router`](https://github.com/lependu/fastify-wamp-router) Web Application Messaging Protocol router for Fastify.
|
|
182
|
+
- [`fast-water`](https://github.com/tswayne/fast-water) A Fastify plugin for waterline. Decorates Fastify with waterline models.
|
|
171
183
|
- [`fastify-webpack-hmr`](https://github.com/lependu/fastify-webpack-hmr) Webpack hot module reloading plugin for Fastify.
|
|
172
|
-
- [`fastify-ws`](https://github.com/gj/fastify-ws) WebSocket integration for Fastify — with support for WebSocket lifecycle hooks instead of a single handler function. Built upon [ws](https://github.com/websockets/ws) and [uws](https://github.com/uNetworking/
|
|
184
|
+
- [`fastify-ws`](https://github.com/gj/fastify-ws) WebSocket integration for Fastify — with support for WebSocket lifecycle hooks instead of a single handler function. Built upon [ws](https://github.com/websockets/ws) and [uws](https://github.com/uNetworking/uWebSockets).
|
|
185
|
+
- [`fastify-xml-body-parser`](https://github.com/NaturalIntelligence/fastify-xml-body-parser) Parse XML payload / request body into JS / JSON object.
|
|
173
186
|
- [`fastify-xray`](https://github.com/jeromemacias/fastify-xray) Fastify plugin for AWS XRay recording.
|
|
174
|
-
- [`@gquittet/graceful-server`](https://github.com/gquittet/graceful-server) Tiny (~5k), Fast, KISS and dependency-free Node.JS library to make your Fastify API graceful.
|
|
175
187
|
- [`i18next-http-middleware`](https://github.com/i18next/i18next-http-middleware#fastify-usage) An [i18next](https://www.i18next.com) based i18n (internationalization) middleware to be used with Node.js web frameworks like express or `Fastify` and also for Deno.
|
|
176
188
|
- [`k-fastify-gateway`](https://github.com/jkyberneees/fastify-gateway) API Gateway plugin for `fastify`, a low footprint implementation that uses the `fastify-reply-from` HTTP proxy library.
|
|
177
189
|
- [`mercurius`](https://mercurius.dev/) A fully-featured and performant GraphQL server implementation for Fastify.
|
package/docs/Encapsulation.md
CHANGED
|
@@ -21,7 +21,7 @@ In the above figure, there are several entities:
|
|
|
21
21
|
- Three _child plugins_
|
|
22
22
|
|
|
23
23
|
Every _child context_ and _grandchild context_ has access to the _root plugins_.
|
|
24
|
-
Within each _child context_ the _grandchild contexts_ have access to the
|
|
24
|
+
Within each _child context_, the _grandchild contexts_ have access to the
|
|
25
25
|
_child plugins_ registered within the containing _child context_, but the
|
|
26
26
|
containing _child context_ **does not** have access to the _child plugins_
|
|
27
27
|
registered within its _grandchild context_.
|
|
@@ -52,7 +52,9 @@ fastify.register(async function authenticatedContext (childServer) {
|
|
|
52
52
|
handler (request, response) {
|
|
53
53
|
response.send({
|
|
54
54
|
answer: request.answer,
|
|
55
|
+
// request.foo will be undefined as it's only defined in publicContext
|
|
55
56
|
foo: request.foo,
|
|
57
|
+
// request.bar will be undefined as it's only defined in grandchildContext
|
|
56
58
|
bar: request.bar
|
|
57
59
|
})
|
|
58
60
|
}
|
|
@@ -69,6 +71,7 @@ fastify.register(async function publicContext (childServer) {
|
|
|
69
71
|
response.send({
|
|
70
72
|
answer: request.answer,
|
|
71
73
|
foo: request.foo,
|
|
74
|
+
// request.bar will be undefined as it's only defined in grandchildContext
|
|
72
75
|
bar: request.bar
|
|
73
76
|
})
|
|
74
77
|
}
|
package/docs/Errors.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
### Error Handling In Node.js
|
|
8
8
|
|
|
9
9
|
#### Uncaught Errors
|
|
10
|
-
In Node.js, uncaught errors are likely to cause memory leaks, file descriptor leaks and other major production issues. [Domains](https://nodejs.org/en/docs/guides/domain-postmortem/) were introduced to try fix this issue, but did not.
|
|
10
|
+
In Node.js, uncaught errors are likely to cause memory leaks, file descriptor leaks and other major production issues. [Domains](https://nodejs.org/en/docs/guides/domain-postmortem/) were introduced to try to fix this issue, but did not.
|
|
11
11
|
|
|
12
12
|
Given that it is not possible to process all uncaught errors sensibly, the best way to deal with them is to [crash](https://nodejs.org/api/process.html#process_warning_using_uncaughtexception_correctly).
|
|
13
13
|
|
|
@@ -34,14 +34,14 @@ For customizing this behaviour, you should use [`setErrorHandler`](Server.md#set
|
|
|
34
34
|
|
|
35
35
|
### Errors In Fastify Lifecycle Hooks And A Custom Error Handler
|
|
36
36
|
|
|
37
|
-
From the [Hooks documentation](Hooks
|
|
37
|
+
From the [Hooks documentation](Hooks.md#manage-errors-from-a-hook):
|
|
38
38
|
> If you get an error during the execution of your hook, just pass it to `done()` and Fastify will automatically close the request and send the appropriate error code to the user.
|
|
39
39
|
|
|
40
40
|
If you have defined a custom error handler for using `setErrorHandler` the error will be routed there, otherwise it will be routed to Fastify’s generic error handler.
|
|
41
41
|
|
|
42
42
|
Some things to consider in your custom error handler:
|
|
43
43
|
|
|
44
|
-
- you can `reply.send(data)` which will be behave as it would be in [regular route handlers](Reply
|
|
44
|
+
- you can `reply.send(data)` which will be behave as it would be in [regular route handlers](Reply.md#senddata)
|
|
45
45
|
- objects are serialised, triggering the `preSerialization` lifecycle hook if you have one defined
|
|
46
46
|
- strings, buffers, and streams are sent to the client, with appropriate headers (no serialization)
|
|
47
47
|
|
|
@@ -63,40 +63,40 @@ The router received an invalid url.
|
|
|
63
63
|
|
|
64
64
|
The parser for this content type was already registered.
|
|
65
65
|
|
|
66
|
-
<a name="
|
|
67
|
-
####
|
|
66
|
+
<a name="FST_ERR_CTP_BODY_TOO_LARGE"></a>
|
|
67
|
+
#### FST_ERR_CTP_BODY_TOO_LARGE
|
|
68
68
|
|
|
69
|
-
The
|
|
69
|
+
The request body is larger than the provided limit.
|
|
70
70
|
|
|
71
71
|
<a name="FST_ERR_CTP_EMPTY_TYPE"></a>
|
|
72
72
|
#### FST_ERR_CTP_EMPTY_TYPE
|
|
73
73
|
|
|
74
74
|
The content type cannot be an empty string.
|
|
75
75
|
|
|
76
|
+
<a name="FST_ERR_CTP_INVALID_CONTENT_LENGTH"></a>
|
|
77
|
+
#### FST_ERR_CTP_INVALID_CONTENT_LENGTH
|
|
78
|
+
|
|
79
|
+
Request body size did not match Content-Length.
|
|
80
|
+
|
|
76
81
|
<a name="FST_ERR_CTP_INVALID_HANDLER"></a>
|
|
77
82
|
#### FST_ERR_CTP_INVALID_HANDLER
|
|
78
83
|
|
|
79
84
|
An invalid handler was passed for the content type.
|
|
80
85
|
|
|
81
|
-
<a name="FST_ERR_CTP_INVALID_PARSE_TYPE"></a>
|
|
82
|
-
#### FST_ERR_CTP_INVALID_PARSE_TYPE
|
|
83
|
-
|
|
84
|
-
The provided parse type is not supported. Accepted values are `string` or `buffer`.
|
|
85
|
-
|
|
86
|
-
<a name="FST_ERR_CTP_BODY_TOO_LARGE"></a>
|
|
87
|
-
#### FST_ERR_CTP_BODY_TOO_LARGE
|
|
88
|
-
|
|
89
|
-
The request body is larger than the provided limit.
|
|
90
|
-
|
|
91
86
|
<a name="FST_ERR_CTP_INVALID_MEDIA_TYPE"></a>
|
|
92
87
|
#### FST_ERR_CTP_INVALID_MEDIA_TYPE
|
|
93
88
|
|
|
94
89
|
The received media type is not supported (i.e. there is no suitable `Content-Type` parser for it).
|
|
95
90
|
|
|
96
|
-
<a name="
|
|
97
|
-
####
|
|
91
|
+
<a name="FST_ERR_CTP_INVALID_PARSE_TYPE"></a>
|
|
92
|
+
#### FST_ERR_CTP_INVALID_PARSE_TYPE
|
|
98
93
|
|
|
99
|
-
|
|
94
|
+
The provided parse type is not supported. Accepted values are `string` or `buffer`.
|
|
95
|
+
|
|
96
|
+
<a name="FST_ERR_CTP_INVALID_TYPE"></a>
|
|
97
|
+
#### FST_ERR_CTP_INVALID_TYPE
|
|
98
|
+
|
|
99
|
+
The `Content-Type` should be a string.
|
|
100
100
|
|
|
101
101
|
<a name="FST_ERR_DEC_ALREADY_PRESENT"></a>
|
|
102
102
|
#### FST_ERR_DEC_ALREADY_PRESENT
|
|
@@ -108,60 +108,60 @@ A decorator with the same name is already registered.
|
|
|
108
108
|
|
|
109
109
|
The decorator cannot be registered due to a missing dependency.
|
|
110
110
|
|
|
111
|
-
<a name="FST_ERR_HOOK_INVALID_TYPE"></a>
|
|
112
|
-
#### FST_ERR_HOOK_INVALID_TYPE
|
|
113
|
-
|
|
114
|
-
The hook name must be a string.
|
|
115
|
-
|
|
116
111
|
<a name="FST_ERR_HOOK_INVALID_HANDLER"></a>
|
|
117
112
|
#### FST_ERR_HOOK_INVALID_HANDLER
|
|
118
113
|
|
|
119
114
|
The hook callback must be a function.
|
|
120
115
|
|
|
116
|
+
<a name="FST_ERR_HOOK_INVALID_TYPE"></a>
|
|
117
|
+
#### FST_ERR_HOOK_INVALID_TYPE
|
|
118
|
+
|
|
119
|
+
The hook name must be a string.
|
|
120
|
+
|
|
121
121
|
<a name="FST_ERR_LOG_INVALID_DESTINATION"></a>
|
|
122
122
|
#### FST_ERR_LOG_INVALID_DESTINATION
|
|
123
123
|
|
|
124
124
|
The logger accepts either a `'stream'` or a `'file'` as the destination.
|
|
125
125
|
|
|
126
|
+
<a name="FST_ERR_PROMISE_NOT_FULFILLED"></a>
|
|
127
|
+
#### FST_ERR_PROMISE_NOT_FULFILLED
|
|
128
|
+
|
|
129
|
+
A promise may not be fulfilled with 'undefined' when statusCode is not 204.
|
|
130
|
+
|
|
126
131
|
<a id="FST_ERR_REP_ALREADY_SENT"></a>
|
|
127
132
|
#### FST_ERR_REP_ALREADY_SENT
|
|
128
133
|
|
|
129
134
|
A response was already sent.
|
|
130
135
|
|
|
131
|
-
<a id="FST_ERR_SEND_INSIDE_ONERR"></a>
|
|
132
|
-
#### FST_ERR_SEND_INSIDE_ONERR
|
|
133
|
-
|
|
134
|
-
You cannot use `send` inside the `onError` hook.
|
|
135
|
-
|
|
136
136
|
<a name="FST_ERR_REP_INVALID_PAYLOAD_TYPE"></a>
|
|
137
137
|
#### FST_ERR_REP_INVALID_PAYLOAD_TYPE
|
|
138
138
|
|
|
139
|
-
Reply payload can either
|
|
140
|
-
|
|
141
|
-
<a name="FST_ERR_SCH_MISSING_ID"></a>
|
|
142
|
-
#### FST_ERR_SCH_MISSING_ID
|
|
143
|
-
|
|
144
|
-
The schema provided does not have `$id` property.
|
|
139
|
+
Reply payload can be either a `string` or a `Buffer`.
|
|
145
140
|
|
|
146
141
|
<a name="FST_ERR_SCH_ALREADY_PRESENT"></a>
|
|
147
142
|
#### FST_ERR_SCH_ALREADY_PRESENT
|
|
148
143
|
|
|
149
144
|
A schema with the same `$id` already exists.
|
|
150
145
|
|
|
151
|
-
<a name="
|
|
152
|
-
####
|
|
146
|
+
<a name="FST_ERR_SCH_MISSING_ID"></a>
|
|
147
|
+
#### FST_ERR_SCH_MISSING_ID
|
|
153
148
|
|
|
154
|
-
The
|
|
149
|
+
The schema provided does not have `$id` property.
|
|
155
150
|
|
|
156
151
|
<a name="FST_ERR_SCH_SERIALIZATION_BUILD"></a>
|
|
157
152
|
#### FST_ERR_SCH_SERIALIZATION_BUILD
|
|
158
153
|
|
|
159
154
|
The JSON schema provided for serialization of a route response is not valid.
|
|
160
155
|
|
|
161
|
-
<a name="
|
|
162
|
-
####
|
|
156
|
+
<a name="FST_ERR_SCH_VALIDATION_BUILD"></a>
|
|
157
|
+
#### FST_ERR_SCH_VALIDATION_BUILD
|
|
163
158
|
|
|
164
|
-
|
|
159
|
+
The JSON schema provided for validation to a route is not valid.
|
|
160
|
+
|
|
161
|
+
<a id="FST_ERR_SEND_INSIDE_ONERR"></a>
|
|
162
|
+
#### FST_ERR_SEND_INSIDE_ONERR
|
|
163
|
+
|
|
164
|
+
You cannot use `send` inside the `onError` hook.
|
|
165
165
|
|
|
166
166
|
<a name="FST_ERR_SEND_UNDEFINED_ERR"></a>
|
|
167
167
|
#### FST_ERR_SEND_UNDEFINED_ERR
|
package/docs/Getting-Started.md
CHANGED
|
@@ -118,7 +118,7 @@ module.exports = routes
|
|
|
118
118
|
In this example, we used the `register` API, which is the core of the Fastify framework. It is the only way to add routes, plugins, et cetera.
|
|
119
119
|
|
|
120
120
|
At the beginning of this guide, we noted that Fastify provides a foundation that assists with asynchronous bootstrapping of your application. Why is this important?
|
|
121
|
-
Consider the scenario where a database connection is needed to handle data storage.
|
|
121
|
+
Consider the scenario where a database connection is needed to handle data storage. The database connection needs to be available before the server is accepting connections. How do we address this problem?<br>
|
|
122
122
|
A typical solution is to use a complex callback, or promises - a system that will mix the framework API with other libraries and the application code.<br>
|
|
123
123
|
Fastify handles this internally, with minimum effort!
|
|
124
124
|
|
|
@@ -285,7 +285,7 @@ fastify.get('/', opts, async (request, reply) => {
|
|
|
285
285
|
return { hello: 'world' }
|
|
286
286
|
})
|
|
287
287
|
```
|
|
288
|
-
|
|
288
|
+
By specifying a schema as shown, you can speed up serialization by a factor of 2-3. This also helps to protect against leakage of potentially sensitive data, since Fastify will serialize only the data present in the response schema.
|
|
289
289
|
Read [Validation and Serialization](Validation-and-Serialization.md) to learn more.
|
|
290
290
|
|
|
291
291
|
<a name="extend-server"></a>
|
package/docs/HTTP2.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
_Fastify_ offers **experimental support** for HTTP2 starting from
|
|
6
6
|
Node 8 LTS, which includes HTTP2 without a flag; HTTP2 is supported
|
|
7
|
-
|
|
7
|
+
over either HTTPS or plaintext.
|
|
8
8
|
|
|
9
9
|
Currently none of the HTTP2-specific APIs are available through
|
|
10
10
|
_Fastify_, but Node's `req` and `res` can be access through our
|