Socket
Socket
Sign inDemoInstall

fastify

Package Overview
Dependencies
60
Maintainers
4
Versions
282
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.26.2 to 4.27.0

test/esm/errorCodes.test.mjs

4

docs/Guides/Database.md

@@ -240,3 +240,3 @@ <h1 align="center">Fastify</h1>

As stated at the beginning of the guide, Fastify is database agnostic and any
NodeJS database migration tool can be used with it. We will give an example of
Node.js database migration tool can be used with it. We will give an example of
using [Postgrator](https://www.npmjs.com/package/postgrator) which has support

@@ -248,3 +248,3 @@ for Postgres, MySQL, SQL Server and SQLite. For MongoDB migrations, please check

Postgrator is NodeJS SQL migration tool that uses a directory of SQL scripts to
Postgrator is Node.js SQL migration tool that uses a directory of SQL scripts to
alter the database schema. Each file an migrations folder need to follow the

@@ -251,0 +251,0 @@ pattern: ` [version].[action].[optional-description].sql`.

@@ -52,3 +52,3 @@ <h1 align="center">Fastify</h1>

[decorating](../Reference/Decorators.md) the `fastify` object with the
authentication key (`magicKey` from here onwards)
authentication key (`magicKey` from here onward)
1. the mechanism for denying requests that would, otherwise, fail

@@ -55,0 +55,0 @@

@@ -90,6 +90,8 @@ <h1 align="center">Fastify</h1>

In the request close event, you should examine the diff between a successful
request and one aborted by the client to determine the best property for your
use case. You can find details about request properties in the
[NodeJS documentation](https://nodejs.org/api/http.html).
Whilst the `aborted` property has been deprecated, `destroyed` is not a
suitable replacement as the
[Node.js documentation suggests](https://nodejs.org/api/http.html#requestaborted).
A request can be `destroyed` for various reasons, such as when the server closes
the connection. The `aborted` property is still the most reliable way to detect
when a client intentionally aborts a request.

@@ -96,0 +98,0 @@ You can also perform this logic outside of a hook, directly in a specific route.

@@ -188,3 +188,3 @@ <h1 align="center">Fastify</h1>

- [`@gquittet/graceful-server`](https://github.com/gquittet/graceful-server)
Tiny (~5k), Fast, KISS, and dependency-free Node.JS library to make your
Tiny (~5k), Fast, KISS, and dependency-free Node.js library to make your
Fastify API graceful.

@@ -226,2 +226,4 @@ - [`@h4ad/serverless-adapter`](https://github.com/H4ad/serverless-adapter)

Kubernetes Liveness and Readiness Probes.
- [`aws-xray-sdk-fastify`](https://github.com/aws/aws-xray-sdk-node/tree/master/sdk_contrib/fastify)
A Fastify plugin to log requests and subsegments through AWSXray.
- [`cls-rtracer`](https://github.com/puzpuzpuz/cls-rtracer) Fastify middleware

@@ -252,5 +254,8 @@ for CLS-based request ID generation. An out-of-the-box solution for adding

- [`fastify-api-key`](https://github.com/arkerone/fastify-api-key) Fastify
plugin to authenticate HTTP requests based on api key and signature
plugin to authenticate HTTP requests based on API key and signature
- [`fastify-appwrite`](https://github.com/Dev-Manny/fastify-appwrite) Fastify
Plugin for interacting with Appwrite server.
- [`fastify-asyncforge`](https://github.com/mcollina/fastify-asyncforge) Plugin
to access Fastify instance, logger, request and reply from Node.js [Async
Local Storage](https://nodejs.org/api/async_context.html#class-asynclocalstorage).
- [`fastify-at-mysql`](https://github.com/mateonunez/fastify-at-mysql) Fastify

@@ -294,3 +299,3 @@ MySQL plugin with auto SQL injection attack prevention.

- [`fastify-cacheman`](https://gitlab.com/aalfiann/fastify-cacheman)
Small and efficient cache provider for Node.JS with In-memory, File, Redis
Small and efficient cache provider for Node.js with In-memory, File, Redis
and MongoDB engines for Fastify

@@ -311,5 +316,3 @@ - [`fastify-casbin`](https://github.com/nearform/fastify-casbin) Casbin support

- [`fastify-cloudinary`](https://github.com/Vanilla-IceCream/fastify-cloudinary)
The Cloudinary Fastify SDK allows you to quickly and easily integrate your
application with Cloudinary. Effortlessly optimize and transform your cloud's
assets.
Plugin to share a common Cloudinary connection across Fastify.
- [`fastify-cockroachdb`](https://github.com/alex-ppg/fastify-cockroachdb)

@@ -424,2 +427,4 @@ Fastify plugin to connect to a CockroachDB PostgreSQL instance via the

Fastify plugin for auto-redirect from HTTP to HTTPS.
- [`fastify-i18n`](https://github.com/Vanilla-IceCream/fastify-i18n)
Internationalization plugin for Fastify. Built upon node-polyglot.
- [`fastify-impressions`](https://github.com/manju4ever/fastify-impressions)

@@ -492,2 +497,5 @@ Fastify plugin to track impressions of all the routes.

and MessagePack, together at last. Uses @msgpack/msgpack by default.
- [`fastify-msgraph-webhook`](https://github.com/flower-of-the-bridges/fastify-msgraph-change-notifications-webhook)
to manage
[MS Graph Change Notifications webhooks](https://learn.microsoft.com/it-it/graph/change-notifications-delivery-webhooks?tabs=http).
- [`fastify-multer`](https://github.com/fox1t/fastify-multer) Multer is a plugin

@@ -579,3 +587,3 @@ for handling multipart/form-data, which is primarily used for uploading files.

- [`fastify-recaptcha`](https://github.com/qwertyforce/fastify-recaptcha)
Fastify plugin for recaptcha verification.
Fastify plugin for reCAPTCHA verification.
- [`fastify-redis-channels`](https://github.com/hearit-io/fastify-redis-channels)

@@ -613,3 +621,3 @@ A plugin for fast, reliable, and scalable channels implementation based on

- [`fastify-sequelize`](https://github.com/lyquocnam/fastify-sequelize) Fastify
plugin work with Sequelize (adapter for NodeJS -> Sqlite, Mysql, Mssql,
plugin work with Sequelize (adapter for Node.js -> Sqlite, Mysql, Mssql,
Postgres).

@@ -694,6 +702,4 @@ - [`fastify-server-session`](https://github.com/jsumners/fastify-server-session)

Parse XML payload / request body into JS / JSON object.
- [`fastify-xray`](https://github.com/jeromemacias/fastify-xray) Fastify plugin
for AWS XRay recording.
- [`http-wizard`](https://github.com/flodlc/http-wizard)
Exports a typescript api client for your Fastify api and ensures fullstack type
Exports a typescript API client for your Fastify API and ensures fullstack type
safety for your project.

@@ -735,1 +741,5 @@ - [`i18next-http-middleware`](https://github.com/i18next/i18next-http-middleware#fastify-usage)

generate JSON Schema from TypeScript interfaces.
- [`vite-plugin-fastify`](https://github.com/Vanilla-IceCream/vite-plugin-fastify)
Fastify plugin for Vite with Hot-module Replacement.
- [`vite-plugin-fastify-routes`](https://github.com/Vanilla-IceCream/vite-plugin-fastify-routes)
File-based routing for Fastify applications using Vite.

@@ -35,2 +35,3 @@ <h1 align="center">Fastify</h1>

import Fastify from 'fastify'
const fastify = Fastify({

@@ -72,2 +73,3 @@ logger: true

import Fastify from 'fastify'
const fastify = Fastify({

@@ -74,0 +76,0 @@ logger: true

@@ -356,3 +356,3 @@ <h1 align="center">Fastify</h1>

As you probably noticed by now, `request` and `reply` are not the standard
Nodejs *request* and *response* objects, but Fastify's objects.
Node.js *request* and *response* objects, but Fastify's objects.

@@ -359,0 +359,0 @@

@@ -46,3 +46,3 @@ > The following is an article written by Eran Hammer.

properties it "inherits" from another object. I have put inherits in quotes
because JavaScript isn't really an object-oriented language.It is prototype-
because JavaScript isn't really an object-oriented language. It is a prototype-
based object-oriented language.

@@ -49,0 +49,0 @@

@@ -317,4 +317,3 @@ <h1 align="center">Fastify</h1>

| <a id="fst_err_rep_invalid_payload_type">FST_ERR_REP_INVALID_PAYLOAD_TYPE</a> | Reply payload can be either a `string` or a `Buffer`. | Use a `string` or a `Buffer` for the payload. | [#1168](https://github.com/fastify/fastify/pull/1168) |
| <a id="fst_err_rep_response_body_consumed">FST_ERR_REP_RESPONSE_BODY_CONSUMED</a> | Using `Response` as reply payload
but the body is being consumed. | Make sure you don't consume the `Response.body` | [#5286](https://github.com/fastify/fastify/pull/5286) |
| <a id="fst_err_rep_response_body_consumed">FST_ERR_REP_RESPONSE_BODY_CONSUMED</a> | Using `Response` as reply payload, but the body is being consumed. | Make sure you don't consume the `Response.body` | [#5286](https://github.com/fastify/fastify/pull/5286) |
| <a id="fst_err_rep_already_sent">FST_ERR_REP_ALREADY_SENT</a> | A response was already sent. | - | [#1336](https://github.com/fastify/fastify/pull/1336) |

@@ -342,3 +341,3 @@ | <a id="fst_err_rep_sent_value">FST_ERR_REP_SENT_VALUE</a> | The only possible value for `reply.sent` is `true`. | - | [#1336](https://github.com/fastify/fastify/pull/1336) |

| <a id="fst_err_duplicated_route">FST_ERR_DUPLICATED_ROUTE</a> | The HTTP method already has a registered controller for that URL. | Use a different URL or register the controller for another HTTP method. | [#2954](https://github.com/fastify/fastify/pull/2954) |
| <a id="fst_err_bad_url">FST_ERR_BAD_URL</a> | The router received an invalid url. | Use a valid URL. | [#2106](https://github.com/fastify/fastify/pull/2106) |
| <a id="fst_err_bad_url">FST_ERR_BAD_URL</a> | The router received an invalid URL. | Use a valid URL. | [#2106](https://github.com/fastify/fastify/pull/2106) |
| <a id="fst_err_async_constraint">FST_ERR_ASYNC_CONSTRAINT</a> | The router received an error when using asynchronous constraints. | - | [#4323](https://github.com/fastify/fastify/pull/4323) |

@@ -345,0 +344,0 @@ | <a id="fst_err_default_route_invalid_type">FST_ERR_DEFAULT_ROUTE_INVALID_TYPE</a> | The `defaultRoute` type should be a function. | Use a function for the `defaultRoute`. | [#2733](https://github.com/fastify/fastify/pull/2733) |

@@ -192,5 +192,7 @@ <h1 align="center">Fastify</h1>

This hook will be executed only after the `customErrorHandler` has been
executed, and only if the `customErrorHandler` sends an error back to the user
*(Note that the default `customErrorHandler` always sends the error back to the
This hook will be executed only after
the [Custom Error Handler set by `setErrorHandler`](./Server.md#seterrorhandler)
has been executed, and only if the custom error handler sends an error back to the
user
*(Note that the default error handler always sends the error back to the
user)*.

@@ -197,0 +199,0 @@

@@ -109,3 +109,3 @@ <h1 align="center">Fastify</h1>

by `req` is the Fastify [`Request`](./Request.md) object, while the object
received by `res` is the Fastify [`Reply`](./Reply.md) object. This behaviour
received by `res` is the Fastify [`Reply`](./Reply.md) object. This behavior
can be customized by specifying custom serializers.

@@ -112,0 +112,0 @@

<h1 align="center">Fastify</h1>
## Long Term Support
<a id="lts"></a>
`<a id="lts"></a>`
Fastify's Long Term Support (LTS) is provided according to the schedule laid out

@@ -13,3 +14,2 @@ in this document:

[https://github.com/fastify/fastify/releases](https://github.com/fastify/fastify/releases).
2. Major releases will receive security updates for an additional six months

@@ -20,3 +20,2 @@ from the release of the next major release. After this period we will still

Node.js version.
3. Major releases will be tested and verified against all Node.js release lines

@@ -27,2 +26,13 @@ that are supported by the [Node.js LTS

of a given line is supported.
4. In addition to Node.js runtime, major releases of Fastify will also be tested
and verified against alternative runtimes that are compatible with Node.js.
The maintenance teams of these alternative runtimes are responsible for ensuring
and guaranteeing these tests work properly.
1. [N|Solid](https://docs.nodesource.com/nsolid), maintained by NodeSource,
commits to testing and verifying each Fastify major release against the N|Solid
LTS versions that are current at the time of the Fastify release.
NodeSource guarantees that Fastify will be compatible and function correctly
with N|Solid, aligning with the support and compatibility scope of the N|Solid
LTS versions available at the time of the Fastify release.
This ensures users of N|Solid can confidently use Fastify.

@@ -44,18 +54,18 @@ A "month" is defined as 30 consecutive days.

[semver]: https://semver.org/
### Schedule
<a id="lts-schedule"></a>
| Version | Release Date | End Of LTS Date | Node.js |
| :------ | :----------- | :-------------- | :------------------- |
| 1.0.0 | 2018-03-06 | 2019-09-01 | 6, 8, 9, 10, 11 |
| 2.0.0 | 2019-02-25 | 2021-01-31 | 6, 8, 10, 12, 14 |
| 3.0.0 | 2020-07-07 | 2023-06-30 | 10, 12, 14, 16, 18 |
| 4.0.0 | 2022-06-08 | TBD | 14, 16, 18, 20 |
`<a id="lts-schedule"></a>`
| Version | Release Date | End Of LTS Date | Node.js | Nsolid(Node) |
| :------ | :----------- | :-------------- | :----------------- | :------------- |
| 1.0.0 | 2018-03-06 | 2019-09-01 | 6, 8, 9, 10, 11 | |
| 2.0.0 | 2019-02-25 | 2021-01-31 | 6, 8, 10, 12, 14 | |
| 3.0.0 | 2020-07-07 | 2023-06-30 | 10, 12, 14, 16, 18 | v5(18) |
| 4.0.0 | 2022-06-08 | TBD | 14, 16, 18, 20 | v5(18), v5(20) |
### CI tested operating systems
<a id="supported-os"></a>
Fastify uses GitHub Actions for CI testing, please refer to [GitHub's
`<a id="supported-os"></a>`
Fastify uses GitHub Actions for CI testing, please refer to [GitHub&#39;s
documentation regarding workflow

@@ -66,10 +76,12 @@ runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources)

| OS | YAML Workflow Label | Package Manager | Node.js |
|---------|------------------------|---------------------------|--------------|
| Linux | `ubuntu-latest` | npm | 14,16,18,20 |
| Linux | `ubuntu-latest` | yarn,pnpm | 14,16,18,20 |
| Windows | `windows-latest` | npm | 14,16,18,20 |
| MacOS | `macos-latest` | npm | 14,16,18,20 |
| OS | YAML Workflow Label | Package Manager | Node.js | Nsolid(Node) |
| ------- | ------------------- | --------------- | ----------- | ------------- |
| Linux | `ubuntu-latest` | npm | 14,16,18,20 | v5(18),v5(20) |
| Linux | `ubuntu-latest` | yarn,pnpm | 14,16,18,20 | v5(18),v5(20) |
| Windows | `windows-latest` | npm | 14,16,18,20 | v5(18),v5(20) |
| MacOS | `macos-latest` | npm | 14,16,18,20 | v5(18),v5(20) |
Using [yarn](https://yarnpkg.com/) might require passing the `--ignore-engines`
flag.
[semver]: https://semver.org/

@@ -65,3 +65,3 @@ <h1 align="center">Fastify</h1>

- `.type(value)` - Sets the header `Content-Type`.
- `.redirect([code,] dest)` - Redirect to the specified url, the status code is
- `.redirect([code,] dest)` - Redirect to the specified URL, the status code is
optional (default to `302`).

@@ -787,3 +787,3 @@ - `.callNotFound()` - Invokes the custom not found handler.

Plese be aware when using `Response`, the status code and headers
Please be aware when using `Response`, the status code and headers
will not directly reflect to `reply.statusCode` and `reply.getHeaders()`.

@@ -847,3 +847,3 @@ Such behavior is based on `Response` only allow `readonly` status

Notice that if the returned status code is not in the response schema list, the
default behaviour will be applied.
default behavior will be applied.

@@ -850,0 +850,0 @@ ```js

@@ -110,3 +110,3 @@ <h1 align="center">Fastify</h1>

console.log(request.url)
console.log(request.routerMethod)
console.log(request.routeOptions.method)
console.log(request.routeOptions.bodyLimit)

@@ -120,3 +120,3 @@ console.log(request.routeOptions.method)

console.log(request.routeOptions.prefixTrailingSlash)
console.log(request.routerPath.logLevel)
console.log(request.routeOptions.logLevel)
request.log.info('some info')

@@ -123,0 +123,0 @@ })

@@ -37,3 +37,4 @@ <h1 align="center">Fastify</h1>

`'POST'`, `'PUT'`, `'OPTIONS'`, `'SEARCH'`, `'TRACE'`, `'PROPFIND'`,
`'PROPPATCH'`, `'MKCOL'`, `'COPY'`, `'MOVE'`, `'LOCK'` and `'UNLOCK'`.
`'PROPPATCH'`, `'MKCOL'`, `'COPY'`, `'MOVE'`, `'LOCK'`, `'UNLOCK'`,
`'REPORT'` and `'MKCALENDAR'`.
It could also be an array of methods.

@@ -46,3 +47,3 @@ * `url`: the path of the URL to match this route (alias: `path`).

* `body`: validates the body of the request if it is a POST, PUT, PATCH,
TRACE, or SEARCH method.
TRACE, SEARCH, PROPFIND, PROPPATCH or LOCK method.
* `querystring` or `query`: validates the querystring. This can be a complete

@@ -49,0 +50,0 @@ JSON Schema object, with the property `type` of `object` and `properties`

@@ -20,7 +20,13 @@ <h1 align="center">Fastify</h1>

- `json-schema-to-ts` -
[github](https://github.com/ThomasAribart/json-schema-to-ts)
- `typebox` - [github](https://github.com/sinclairzx81/typebox)
- `zod` - [github](https://github.com/colinhacks/zod)
- [`json-schema-to-ts`](https://github.com/ThomasAribart/json-schema-to-ts)
- [`typebox`](https://github.com/sinclairzx81/typebox)
- [`zod`](https://github.com/colinhacks/zod)
See also the Type Provider wrapper packages for each of the packages respectively:
- [`@fastify/type-provider-json-schema-to-ts`](https://github.com/fastify/fastify-type-provider-json-schema-to-ts)
- [`@fastify/type-provider-typebox`](https://github.com/fastify/fastify-type-provider-typebox)
- [`fastify-type-provider-zod`](https://github.com/turkerdev/fastify-type-provider-zod)
(3rd party)
### Json Schema to Ts

@@ -27,0 +33,0 @@

@@ -37,3 +37,3 @@ <h1 align="center">Fastify</h1>

1. Create a new npm project, install Fastify, and install typescript & node.js
1. Create a new npm project, install Fastify, and install typescript & Node.js
types as peer dependencies:

@@ -65,7 +65,2 @@ ```bash

*Note 2: Avoid using ```"moduleResolution": "NodeNext"``` in tsconfig.json with
```"type": "module"``` in package.json. This combination is currently not
supported by fastify typing system.
[ts(2349)](https://github.com/fastify/fastify/issues/4241) warning.*
4. Create an `index.ts` file - this will contain the server code

@@ -162,3 +157,3 @@ 5. Add the following code block to your file:

4. Build and run the server code with `npm run build` and `npm run start`
5. Query the api
5. Query the API
```bash

@@ -213,17 +208,19 @@ curl localhost:8080/auth?username=admin&password=Password123!

- `@fastify/type-provider-json-schema-to-ts`
- `@fastify/type-provider-typebox`
- [`@fastify/type-provider-json-schema-to-ts`](https://github.com/fastify/fastify-type-provider-json-schema-to-ts)
- [`@fastify/type-provider-typebox`](https://github.com/fastify/fastify-type-provider-typebox)
And a `zod` wrapper by a third party called [`fastify-type-provider-zod`](https://github.com/turkerdev/fastify-type-provider-zod)
They simplify schema validation setup and you can read more about them in [Type
Providers](./Type-Providers.md) page.
Below is how to setup schema validation using vanilla `typebox` and
Below is how to setup schema validation using _vanilla_ `typebox` and
`json-schema-to-ts` packages.
#### typebox
#### TypeBox
A useful library for building types and a schema at once is
[typebox](https://www.npmjs.com/package/@sinclair/typebox) along with
[TypeBox](https://www.npmjs.com/package/@sinclair/typebox) along with
[fastify-type-provider-typebox](https://github.com/fastify/fastify-type-provider-typebox).
With typebox you define your schema within your code and use them
With TypeBox you define your schema within your code and use them
directly as types or schemas as you need them.

@@ -281,3 +278,2 @@

#### Schemas in JSON Files

@@ -729,5 +725,5 @@

Default](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html#generic-parameter-defaults)
- [Generic
Constraints](https://www.typescriptlang.org/docs/handbook/generics.html#generic-constraints)
- [Generic Constraints](https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-constraints)
#### How to import

@@ -875,5 +871,10 @@

```
2. Follow the steps in this official [Node.js https server
guide](https://nodejs.org/en/knowledge/HTTP/servers/how-to-create-a-HTTPS-server/)
to create the `key.pem` and `cert.pem` files
2. Perform the following steps before setting up a Fastify HTTPS server
to create the `key.pem` and `cert.pem` files:
```sh
openssl genrsa -out key.pem
openssl req -new -key key.pem -out csr.pem
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
rm csr.pem
```
3. Instantiate a Fastify https server and add a route:

@@ -981,3 +982,3 @@ ```typescript

Dependant on `@types/node` modules `http`, `https`, `http2`
Dependent on `@types/node` modules `http`, `https`, `http2`

@@ -990,3 +991,3 @@ Union type of: `http.Server | https.Server | http2.Http2Server |

Dependant on `@types/node` modules `http`
Dependent on `@types/node` modules `http`

@@ -1110,3 +1111,3 @@ Type alias for `http.Server`

Dependant on `@types/node` modules `http`, `https`, `http2`
Dependent on `@types/node` modules `http`, `https`, `http2`

@@ -1171,3 +1172,3 @@ Generic parameter `RawServer` defaults to [`RawServerDefault`][RawServerDefault]

Dependant on `@types/node` modules `http`, `https`, `http2`
Dependent on `@types/node` modules `http`, `https`, `http2`

@@ -1256,3 +1257,3 @@ Generic parameter `RawServer` defaults to [`RawServerDefault`][RawServerDefault]

const plugin: FastifyPluginCallback<{
: option1: string;
option1: string;
option2: boolean;

@@ -1259,0 +1260,0 @@ }> = function (instance, opts, done) { }

@@ -438,3 +438,3 @@ <h1 align="center">Fastify</h1>

The `setValidatorCompiler` function makes it easy to substitute `ajv` with
almost any Javascript validation library ([joi](https://github.com/hapijs/joi/),
almost any JavaScript validation library ([joi](https://github.com/hapijs/joi/),
[yup](https://github.com/jquense/yup/), ...) or a custom one:

@@ -441,0 +441,0 @@

'use strict'
const VERSION = '4.26.2'
const VERSION = '4.27.0'

@@ -729,3 +729,3 @@ const Avvio = require('avvio')

this.log.trace({ err }, `client ${errorLabel}`)
// Copying standard node behaviour
// Copying standard node behavior
// https://github.com/nodejs/node/blob/6ca23d7846cb47e84fd344543e394e50938540be/lib/_http_server.js#L666

@@ -897,4 +897,2 @@

fastify.errorCodes = errorCodes
function validateSchemaErrorFormatter (schemaErrorFormatter) {

@@ -920,3 +918,4 @@ if (typeof schemaErrorFormatter !== 'function') {

module.exports = fastify
module.exports.errorCodes = errorCodes
module.exports.fastify = fastify
module.exports.default = fastify

@@ -10,3 +10,4 @@ 'use strict'

kReplyHasStatusCode,
kRouteContext
kRouteContext,
kDisableRequestLogging
} = require('./symbols.js')

@@ -39,6 +40,8 @@

} catch (error) {
reply.log.warn(
{ req: reply.request, res: reply, err: error },
error && error.message
)
if (!reply.log[kDisableRequestLogging]) {
reply.log.warn(
{ req: reply.request, res: reply, err: error },
error && error.message
)
}
reply.raw.writeHead(reply.raw.statusCode)

@@ -67,9 +70,13 @@ }

const result = func(error, reply.request, reply)
if (result !== undefined) {
if (result !== null && typeof result.then === 'function') {
wrapThenable(result, reply)
} else {
reply.send(result)
try {
const result = func(error, reply.request, reply)
if (result !== undefined) {
if (result !== null && typeof result.then === 'function') {
wrapThenable(result, reply)
} else {
reply.send(result)
}
}
} catch (err) {
reply.send(err)
}

@@ -85,11 +92,15 @@ }

if (reply.statusCode < 500) {
reply.log.info(
{ res: reply, err: error },
error && error.message
)
if (!reply.log[kDisableRequestLogging]) {
reply.log.info(
{ res: reply, err: error },
error && error.message
)
}
} else {
reply.log.error(
{ req: request, res: reply, err: error },
error && error.message
)
if (!reply.log[kDisableRequestLogging]) {
reply.log.error(
{ req: request, res: reply, err: error },
error && error.message
)
}
}

@@ -119,4 +130,6 @@ reply.send(error)

} catch (err) {
// error is always FST_ERR_SCH_SERIALIZATION_BUILD because this is called from route/compileSchemasForSerialization
reply.log.error({ err, statusCode: res.statusCode }, 'The serializer for the given status code failed')
if (!reply.log[kDisableRequestLogging]) {
// error is always FST_ERR_SCH_SERIALIZATION_BUILD because this is called from route/compileSchemasForSerialization
reply.log.error({ err, statusCode: res.statusCode }, 'The serializer for the given status code failed')
}
reply.code(500)

@@ -123,0 +136,0 @@ payload = serializeError(new FST_ERR_FAILED_ERROR_SERIALIZATION(err.message, error.message))

@@ -26,3 +26,3 @@ 'use strict'

* Each fastify instance have a:
* kFourOhFourLevelInstance: point to a fastify instance that has the 404 handler setted
* kFourOhFourLevelInstance: point to a fastify instance that has the 404 handler set
* kCanSetNotFoundHandler: bool to track if the 404 handler has already been set

@@ -33,3 +33,3 @@ * kFourOhFour: the singleton instance of this 404 module

function fourOhFour (options) {
const { logger } = options
const { logger, disableRequestLogging } = options

@@ -54,3 +54,5 @@ // 404 router, used for handling encapsulated 404 handlers

const message = `Route ${method}:${url} not found`
request.log.info(message)
if (!disableRequestLogging) {
request.log.info(message)
}
reply.code(404).send({

@@ -57,0 +59,0 @@ message,

@@ -30,3 +30,4 @@ 'use strict'

if (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'TRACE' || method === 'SEARCH') {
if (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'TRACE' || method === 'SEARCH' ||
method === 'PROPFIND' || method === 'PROPPATCH' || method === 'LOCK' || method === 'REPORT' || method === 'MKCALENDAR') {
if (contentType === undefined) {

@@ -33,0 +34,0 @@ if (

@@ -20,4 +20,6 @@ 'use strict'

'TRACE',
'SEARCH'
'SEARCH',
'REPORT',
'MKCALENDAR'
]
}

@@ -42,2 +42,4 @@ 'use strict'

reply.send(err)
// The following should not happen
/* c8 ignore next 3 */
} catch (err) {

@@ -44,0 +46,0 @@ reply.send(err)

{
"name": "fastify",
"version": "4.26.2",
"version": "4.27.0",
"description": "Fast and low overhead web framework, for Node.js",

@@ -132,3 +132,3 @@ "main": "fastify.js",

"name": "Gürgün Dayıoğlu",
"email": "gurgun.dayioglu@icloud.com",
"email": "hey@gurgun.day",
"url": "https://heyhey.to/G"

@@ -213,3 +213,3 @@ },

"light-my-request": "^5.11.0",
"pino": "^8.17.0",
"pino": "^9.0.0",
"process-warning": "^3.0.0",

@@ -216,0 +216,0 @@ "proxy-addr": "^2.0.7",

@@ -128,2 +128,3 @@ <div align="center"> <a href="https://fastify.dev/">

import Fastify from 'fastify'
const fastify = Fastify({

@@ -154,2 +155,3 @@ logger: true

import Fastify from 'fastify'
const fastify = Fastify({

@@ -328,2 +330,4 @@ logger: true

<https://www.npmjs.com/~uzlopak>
* [__Gürgün Dayıoğlu__](https://github.com/gurgunday),
<https://www.npmjs.com/~gurgunday>

@@ -330,0 +334,0 @@ ### Fastify Plugins team

@@ -16,3 +16,3 @@ # Sponsors

_Be the first!_
- [Mercedes-Benz Group](https://github.com/mercedes-benz)

@@ -19,0 +19,0 @@ ## Tier 2

@@ -1084,3 +1084,3 @@ 'use strict'

t.throws(() => fastify.inject({
method: 'UNKNWON_METHOD',
method: 'UNKNOWN_METHOD',
url: '/'

@@ -1090,3 +1090,3 @@ }, handler), Error)

sget({
method: 'UNKNWON_METHOD',
method: 'UNKNOWN_METHOD',
url: getServerUrl(fastify)

@@ -1093,0 +1093,0 @@ }, (err, response, body) => {

@@ -191,1 +191,33 @@ 'use strict'

})
test('catch synchronous errors', t => {
t.plan(3)
const fastify = Fastify()
t.teardown(fastify.close.bind(fastify))
fastify.setErrorHandler((_, req, reply) => {
throw new Error('kaboom2')
})
fastify.post('/', function (req, reply) {
reply.send(new Error('kaboom'))
})
fastify.inject({
method: 'POST',
url: '/',
headers: {
'Content-Type': 'application/json'
},
payload: JSON.stringify({ hello: 'world' }).substring(0, 5)
}, (err, res) => {
t.error(err)
t.equal(res.statusCode, 500)
t.same(res.json(), {
error: 'Internal Server Error',
message: 'kaboom2',
statusCode: 500
})
})
})

@@ -266,3 +266,3 @@ 'use strict'

client.on('error', function () {
// Dependending on the Operating System
// Depending on the Operating System
// the socket could error or not.

@@ -269,0 +269,0 @@ // However, it will always be closed.

@@ -6,3 +6,3 @@ 'use strict'

test('encapuslates an error handler', async t => {
test('encapsulates an error handler', async t => {
t.plan(3)

@@ -9,0 +9,0 @@

@@ -16,5 +16,5 @@ 'use strict'

function schemaValidator ({ schema, method, url, httpPart }) {
const validateFuncion = ajv.compile(schema)
const validateFunction = ajv.compile(schema)
const fn = function (body) {
const isOk = validateFuncion(body)
const isOk = validateFunction(body)
if (isOk) return

@@ -21,0 +21,0 @@ return false

@@ -8,2 +8,11 @@ 'use strict'

const bodySample = `<?xml version="1.0" encoding="utf-8" ?>
<D:lockinfo xmlns:D='DAV:'>
<D:lockscope> <D:exclusive/> </D:lockscope>
<D:locktype> <D:write/> </D:locktype>
<D:owner>
<D:href>http://example.org/~ejw/contact.html</D:href>
</D:owner>
</D:lockinfo> `
test('can be created - lock', t => {

@@ -53,16 +62,14 @@ t.plan(1)

t.error(err)
t.teardown(() => { fastify.close() })
t.teardown(() => {
fastify.close()
})
test('request - lock', t => {
// the body test uses a text/plain content type instead of application/xml because it requires
// a specific content type parser
test('request with body - lock', t => {
t.plan(3)
sget({
url: `http://localhost:${fastify.server.address().port}/test/a.txt`,
body: `<?xml version="1.0" encoding="utf-8" ?>
<D:lockinfo xmlns:D='DAV:'>
<D:lockscope> <D:exclusive/> </D:lockscope>
<D:locktype> <D:write/> </D:locktype>
<D:owner>
<D:href>http://example.org/~ejw/contact.html</D:href>
</D:owner>
</D:lockinfo> `,
headers: { 'content-type': 'text/plain' },
body: bodySample,
method: 'LOCK'

@@ -75,2 +82,28 @@ }, (err, response, body) => {

})
test('request with body and no content type (415 error) - lock', t => {
t.plan(3)
sget({
url: `http://localhost:${fastify.server.address().port}/test/a.txt`,
body: bodySample,
method: 'LOCK'
}, (err, response, body) => {
t.error(err)
t.equal(response.statusCode, 415)
t.equal(response.headers['content-length'], '' + body.length)
})
})
test('request without body - lock', t => {
t.plan(3)
sget({
url: `http://localhost:${fastify.server.address().port}/test/a.txt`,
headers: { 'content-type': 'text/plain' },
method: 'LOCK'
}, (err, response, body) => {
t.error(err)
t.equal(response.statusCode, 200)
t.equal(response.headers['content-length'], '' + body.length)
})
})
})

@@ -52,3 +52,3 @@ 'use strict'

const regex = lines.shift()
t.ok(regex.test(line.msg), '"' + line.msg + '" dont match "' + regex + '"')
t.ok(regex.test(line.msg), '"' + line.msg + '" does not match "' + regex + '"')
if (lines.length === 0) break

@@ -55,0 +55,0 @@ }

@@ -20,3 +20,3 @@ 'use strict'

t.plan(12)
t.plan(13)

@@ -257,3 +257,3 @@ t.before(async function () {

t.test('should not log incoming request and outgoing response when disabled', async (t) => {
t.plan(3)
t.plan(1)
const stream = split(JSON.parse)

@@ -271,8 +271,2 @@ const fastify = Fastify({ disableRequestLogging: true, logger: { level: 'info', stream } })

{
const [line] = await once(stream, 'data')
t.ok(line.reqId, 'reqId is defined')
t.equal(line.msg, '500 error', 'message is set')
}
// no more readable data

@@ -282,4 +276,4 @@ t.equal(stream.readableLength, 0)

t.test('should not log incoming request and outgoing response for 404 onBadUrl when disabled', async (t) => {
t.plan(3)
t.test('should not log incoming request, outgoing response and route not found for 404 onBadUrl when disabled', async (t) => {
t.plan(1)
const stream = split(JSON.parse)

@@ -293,8 +287,2 @@ const fastify = Fastify({ disableRequestLogging: true, logger: { level: 'info', stream } })

{
const [line] = await once(stream, 'data')
t.ok(line.reqId, 'reqId is defined')
t.equal(line.msg, 'Route GET:/%c0 not found', 'message is set')
}
// no more readable data

@@ -411,2 +399,35 @@ t.equal(stream.readableLength, 0)

})
t.test('should not log the error if request logging is disabled', async (t) => {
t.plan(4)
const stream = split(JSON.parse)
const fastify = Fastify({
logger: {
stream,
level: 'info'
},
disableRequestLogging: true
})
t.teardown(fastify.close.bind(fastify))
fastify.get('/error', function (req, reply) {
t.ok(req.log)
reply.send(new Error('a generic error'))
})
await fastify.ready()
await fastify.listen({ port: 0, host: localhost })
await request(`http://${localhostForURL}:` + fastify.server.address().port + '/error')
{
const [line] = await once(stream, 'data')
t.type(line.msg, 'string')
t.ok(line.msg.startsWith('Server listening at'), 'message is set')
}
// no more readable data
t.equal(stream.readableLength, 0)
})
})

@@ -17,3 +17,3 @@ 'use strict'

t.test('logger can be silented', (t) => {
t.test('logger can be silenced', (t) => {
t.plan(17)

@@ -20,0 +20,0 @@ const fastify = Fastify({

@@ -8,2 +8,10 @@ 'use strict'

const bodySample = `<?xml version="1.0" encoding="utf-8" ?>
<D:propfind xmlns:D="DAV:">
<D:prop xmlns:R="http://ns.example.com/boxschema/">
<R:bigbox/> <R:author/> <R:DingALing/> <R:Random/>
</D:prop>
</D:propfind>
`
test('can be created - propfind', t => {

@@ -65,3 +73,5 @@ t.plan(1)

t.error(err)
t.teardown(() => { fastify.close() })
t.teardown(() => {
fastify.close()
})

@@ -92,2 +102,4 @@ test('request - propfind', t => {

// the body test uses a text/plain content type instead of application/xml because it requires
// a specific content type parser
test('request with body - propfind', t => {

@@ -97,9 +109,4 @@ t.plan(3)

url: `http://localhost:${fastify.server.address().port}/test`,
body: `<?xml version="1.0" encoding="utf-8" ?>
<D:propfind xmlns:D="DAV:">
<D:prop xmlns:R="http://ns.example.com/boxschema/">
<R:bigbox/> <R:author/> <R:DingALing/> <R:Random/>
</D:prop>
</D:propfind>
`,
headers: { 'content-type': 'text/plain' },
body: bodySample,
method: 'PROPFIND'

@@ -112,2 +119,27 @@ }, (err, response, body) => {

})
test('request with body and no content type (415 error) - propfind', t => {
t.plan(3)
sget({
url: `http://localhost:${fastify.server.address().port}/test`,
body: bodySample,
method: 'PROPFIND'
}, (err, response, body) => {
t.error(err)
t.equal(response.statusCode, 415)
t.equal(response.headers['content-length'], '' + body.length)
})
})
test('request without body - propfind', t => {
t.plan(3)
sget({
url: `http://localhost:${fastify.server.address().port}/test`,
method: 'PROPFIND'
}, (err, response, body) => {
t.error(err)
t.equal(response.statusCode, 207)
t.equal(response.headers['content-length'], '' + body.length)
})
})
})

@@ -8,2 +8,20 @@ 'use strict'

const bodySample = `<?xml version="1.0" encoding="utf-8" ?>
<D:propertyupdate xmlns:D="DAV:"
xmlns:Z="http://ns.example.com/standards/z39.50/">
<D:set>
<D:prop>
<Z:Authors>
<Z:Author>Jim Whitehead</Z:Author>
<Z:Author>Roy Fielding</Z:Author>
</Z:Authors>
</D:prop>
</D:set>
<D:remove>
<D:prop>
<Z:Copyright-Owner/>
</D:prop>
</D:remove>
</D:propertyupdate>`
test('shorthand - proppatch', t => {

@@ -51,23 +69,10 @@ t.plan(1)

test('request - proppatch', t => {
// the body test uses a text/plain content type instead of application/xml because it requires
// a specific content type parser
test('request with body - proppatch', t => {
t.plan(3)
sget({
url: `http://localhost:${fastify.server.address().port}/test/a.txt`,
body: `<?xml version="1.0" encoding="utf-8" ?>
<D:propertyupdate xmlns:D="DAV:"
xmlns:Z="http://ns.example.com/standards/z39.50/">
<D:set>
<D:prop>
<Z:Authors>
<Z:Author>Jim Whitehead</Z:Author>
<Z:Author>Roy Fielding</Z:Author>
</Z:Authors>
</D:prop>
</D:set>
<D:remove>
<D:prop>
<Z:Copyright-Owner/>
</D:prop>
</D:remove>
</D:propertyupdate>`,
headers: { 'content-type': 'text/plain' },
body: bodySample,
method: 'PROPPATCH'

@@ -80,2 +85,27 @@ }, (err, response, body) => {

})
test('request with body and no content type (415 error) - proppatch', t => {
t.plan(3)
sget({
url: `http://localhost:${fastify.server.address().port}/test/a.txt`,
body: bodySample,
method: 'PROPPATCH'
}, (err, response, body) => {
t.error(err)
t.equal(response.statusCode, 415)
t.equal(response.headers['content-length'], '' + body.length)
})
})
test('request without body - proppatch', t => {
t.plan(3)
sget({
url: `http://localhost:${fastify.server.address().port}/test/a.txt`,
method: 'PROPPATCH'
}, (err, response, body) => {
t.error(err)
t.equal(response.statusCode, 207)
t.equal(response.headers['content-length'], '' + body.length)
})
})
})

@@ -323,3 +323,3 @@ 'use strict'

201: {
// the contract sintax
// the contract syntax
value: { type: 'string' }

@@ -326,0 +326,0 @@ }

@@ -210,3 +210,3 @@ 'use strict'

t.equal(err.code, 'FST_ERR_SCH_SERIALIZATION_BUILD')
t.match(err.message, /^Failed building the serialization schema for GET: \/:id, due to error Cannot find reference.*/) // error from fast-json-strinfigy
t.match(err.message, /^Failed building the serialization schema for GET: \/:id, due to error Cannot find reference.*/) // error from fast-json-stringify
})

@@ -1271,3 +1271,3 @@ })

// this trigger to dont't reuse the same compiler pool
// this trigger to don't reuse the same compiler pool
instance.addSchema({ $id: 'diff', type: 'object' })

@@ -1560,3 +1560,3 @@

t.equal(json.statusCode, 400)
t.equal(res.statusCode, 400, 'Should not coearce the string into array')
t.equal(res.statusCode, 400, 'Should not coerce the string into array')
})

@@ -1791,3 +1791,3 @@

t.equal(childSerializerCalled, 1, 'Should be called from the child')
t.equal(res.statusCode, 400, 'Should not coearce the string into array')
t.equal(res.statusCode, 400, 'Should not coerce the string into array')
})

@@ -1874,3 +1874,3 @@

t.equal(res.json().message, 'querystring/msg must be array')
t.equal(res.statusCode, 400, 'Should not coearce the string into array')
t.equal(res.statusCode, 400, 'Should not coerce the string into array')
} catch (err) {

@@ -1936,3 +1936,3 @@ t.error(err)

t.equal(res.statusCode, 200)
t.same(res.json(), { msg: ['string'] }, 'Should coearce the string into array')
t.same(res.json(), { msg: ['string'] }, 'Should coerce the string into array')
} catch (err) {

@@ -1939,0 +1939,0 @@ t.error(err)

@@ -58,3 +58,3 @@ 'use strict'

t.error(err)
t.equal(res.payload, '5', 'it must use the ceil rouding')
t.equal(res.payload, '5', 'it must use the ceil rounding')
t.equal(res.statusCode, 200)

@@ -949,3 +949,3 @@ })

test('Errors in searilizer sended to errorHandler', async t => {
test('Errors in serializer send to errorHandler', async t => {
let savedError

@@ -952,0 +952,0 @@

@@ -706,3 +706,3 @@ 'use strict'

test('The default schema compilers should not be called when overwritte by the user', async t => {
test('The default schema compilers should not be called when overwritten by the user', async t => {
const Fastify = t.mock('../', {

@@ -709,0 +709,0 @@ '@fastify/ajv-compiler': () => {

@@ -223,3 +223,3 @@ 'use strict'

test('Throwing an error doesnt trigger any hooks', t => {
test('Throwing an error does not trigger any hooks', t => {
const stream = split(JSON.parse)

@@ -226,0 +226,0 @@ const app = Fastify({

@@ -153,3 +153,3 @@ 'use strict'

stream.push('<h1>should disply on second stream</h1>')
stream.push('<h1>should display on second stream</h1>')
stream.push(null)

@@ -188,3 +188,3 @@ return reply

res.on('end', function () {
t.equal(payload, '<h1>HTML</h1><h1>should disply on second stream</h1>')
t.equal(payload, '<h1>HTML</h1><h1>should display on second stream</h1>')
t.pass('should end properly')

@@ -191,0 +191,0 @@ })

@@ -256,3 +256,3 @@ import { expectAssignable, expectDeprecated, expectError, expectNotDeprecated, expectType } from 'tsd'

// test listen opts objects Typescript deprectation exclusion
// test listen opts objects Typescript deprecation exclusion
expectNotDeprecated(server.listen())

@@ -259,0 +259,0 @@ expectNotDeprecated(server.listen({ port: 3000 }))

@@ -45,4 +45,4 @@ import { Buffer } from 'buffer'

expectType<FastifyInstance>(reply.server)
expectAssignable<((httpStatus: string) => DefaultSerializationFunction)>(reply.getSerializationFunction)
expectAssignable<((schema: {[key: string]: unknown}) => DefaultSerializationFunction)>(reply.getSerializationFunction)
expectAssignable<((httpStatus: string) => DefaultSerializationFunction | undefined)>(reply.getSerializationFunction)
expectAssignable<((schema: {[key: string]: unknown}) => DefaultSerializationFunction | undefined)>(reply.getSerializationFunction)
expectAssignable<((schema: {[key: string]: unknown}, httpStatus?: string) => DefaultSerializationFunction)>(reply.compileSerializationSchema)

@@ -49,0 +49,0 @@ expectAssignable<((input: {[key: string]: unknown}, schema: {[key: string]: unknown}, httpStatus?: string) => unknown)>(reply.serializeInput)

@@ -82,4 +82,4 @@ import { expectAssignable, expectType } from 'tsd'

expectType<ContextConfigDefault & FastifyRouteConfig & FastifyContextConfig>(request.routeOptions.config)
expectType<FastifySchema>(request.routeSchema)
expectType<FastifySchema>(request.routeOptions.schema)
expectType<FastifySchema | undefined>(request.routeSchema)
expectType<FastifySchema | undefined>(request.routeOptions.schema)
expectType<RouteHandlerMethod>(request.routeOptions.handler)

@@ -86,0 +86,0 @@ expectType<string | undefined>(request.routeOptions.url)

@@ -167,3 +167,3 @@ import fastify, {

// infering schema `as const`
// inferring schema `as const`

@@ -473,3 +473,5 @@ expectAssignable(server.withTypeProvider<JsonSchemaToTsProvider>().get(

res.send({ error: 'error' })
expectType<(payload?: string | number | { error: string }) => typeof res>(res.code(200).send)
expectType<(payload?: string) => typeof res>(res.code(200).send)
expectType<(payload?: number) => typeof res>(res.code(400).send)
expectType<(payload?: { error: string }) => typeof res>(res.code(500).send)
expectError<(payload?: unknown) => typeof res>(res.code(200).send)

@@ -704,3 +706,5 @@ }

res.send({ error: 'error' })
expectType<(payload?: string | number | { [x: string]: unknown, error?: string | undefined }) => typeof res>(res.code(200).send)
expectType<(payload?: string) => typeof res>(res.code(200).send)
expectType<(payload?: number) => typeof res>(res.code(400).send)
expectType<(payload?: { [x: string]: unknown; error?: string }) => typeof res>(res.code(500).send)
expectError<(payload?: unknown) => typeof res>(res.code(200).send)

@@ -707,0 +711,0 @@ }

@@ -8,3 +8,3 @@ import { Buffer } from 'buffer'

import { FastifySchema } from './schema'
import { FastifyReplyType, FastifyTypeProvider, FastifyTypeProviderDefault, ResolveFastifyReplyType } from './type-provider'
import { FastifyReplyType, FastifyTypeProvider, FastifyTypeProviderDefault, ResolveFastifyReplyType, CallTypeProvider } from './type-provider'
import { CodeToReplyKey, ContextConfigDefault, HttpKeys, RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerBase, RawServerDefault, ReplyDefault, ReplyKeysToCodes, HttpHeader } from './utils'

@@ -27,3 +27,5 @@

TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault> =
ResolveFastifyReplyType<TypeProvider, SchemaCompiler, { Reply: ReplyTypeConstrainer<RouteGenericReply, Code> }>
Code extends keyof SchemaCompiler['response'] ?
CallTypeProvider<TypeProvider, SchemaCompiler['response'][Code]> :
ResolveFastifyReplyType<TypeProvider, SchemaCompiler, { Reply: ReplyTypeConstrainer<RouteGenericReply, Code> }>
/**

@@ -73,4 +75,4 @@ * FastifyReply is an instance of the standard http or http2 reply types.

// Serialization Methods
getSerializationFunction(httpStatus: string, contentType?: string): (payload: {[key: string]: unknown}) => string;
getSerializationFunction(schema: {[key: string]: unknown}): (payload: {[key: string]: unknown}) => string;
getSerializationFunction(httpStatus: string, contentType?: string): ((payload: {[key: string]: unknown}) => string) | undefined;
getSerializationFunction(schema: {[key: string]: unknown}): ((payload: {[key: string]: unknown}) => string) | undefined;
compileSerializationSchema(schema: {[key: string]: unknown}, httpStatus?: string, contentType?: string): (payload: {[key: string]: unknown}) => string;

@@ -77,0 +79,0 @@ serializeInput(input: {[key: string]: unknown}, schema: {[key: string]: unknown}, httpStatus?: string, contentType?: string): string;

@@ -34,3 +34,3 @@ import { ErrorObject } from '@fastify/ajv-compiler'

config: FastifyContextConfig & FastifyRouteConfig & ContextConfig;
schema: SchemaCompiler;
schema?: SchemaCompiler; // it is empty for 404 requests
handler: RouteHandlerMethod;

@@ -68,3 +68,3 @@ }

routeConfig: FastifyRequestContext<ContextConfig>['config'];
routeSchema: FastifySchema
routeSchema?: FastifySchema; // it is empty for 404 requests

@@ -71,0 +71,0 @@ /** in order for this to be used the user should ensure they have set the attachValidation option. */

@@ -75,3 +75,3 @@ import { RouteGenericInterface } from './route'

// resolution strategy to Requests where the Reply will infer a union of each status code type specified
// by the user. The Reply can be explicitly overriden by users providing a generic Reply type on the route.
// by the user. The Reply can be explicitly overridden by users providing a generic Reply type on the route.
export type ResolveFastifyReplyType<TypeProvider extends FastifyTypeProvider, SchemaCompiler extends FastifySchema, RouteGeneric extends RouteGenericInterface> = UndefinedToUnknown<KeysOf<RouteGeneric['Reply']> extends never ? ResolveReplyFromSchemaCompiler<TypeProvider, SchemaCompiler> : RouteGeneric['Reply']>

@@ -78,0 +78,0 @@

@@ -9,3 +9,3 @@ import * as http from 'http'

type _HTTPMethods = 'DELETE' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'OPTIONS' |
'PROPFIND' | 'PROPPATCH' | 'MKCOL' | 'COPY' | 'MOVE' | 'LOCK' | 'UNLOCK' | 'TRACE' | 'SEARCH'
'PROPFIND' | 'PROPPATCH' | 'MKCOL' | 'COPY' | 'MOVE' | 'LOCK' | 'UNLOCK' | 'TRACE' | 'SEARCH' | 'REPORT' | 'MKCALENDAR'

@@ -12,0 +12,0 @@ export type HTTPMethods = Uppercase<_HTTPMethods> | Lowercase<_HTTPMethods>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc