Socket
Socket
Sign inDemoInstall

fastify

Package Overview
Dependencies
Maintainers
3
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify - npm Package Compare versions

Comparing version 4.2.0 to 4.2.1

4

docs/Guides/Database.md

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

export default fp(plugin, { name: 'fastify-knex-example' })
export default fp(knexPlugin, { name: 'fastify-knex-example' })
```

@@ -217,3 +217,3 @@

```javascript
const fp = require('fp')
const fp = require('fastify-plugin')
const mysql = require('mysql2/promise')

@@ -220,0 +220,0 @@

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

- [`@h4ad/serverless-adapter`](https://github.com/H4ad/serverless-adapter)
Run REST APIs and other web applications using your existing Node.js
application framework (Express, Koa, Hapi and Fastify), on top of AWS Lambda,
Run REST APIs and other web applications using your existing Node.js
application framework (Express, Koa, Hapi and Fastify), on top of AWS Lambda,
Huawei and many other clouds.

@@ -155,2 +155,4 @@ - [`@immobiliarelabs/fastify-metrics`](https://github.com/immobiliare/fastify-metrics)

A plugin to enable compact request logging for Fastify
- [`@mgcrea/fastify-session`](https://github.com/mgcrea/fastify-session) Session
plugin for Fastify that supports both stateless and stateful sessions
- [`@mgcrea/fastify-session-redis-store`](https://github.com/mgcrea/fastify-session-redis-store)

@@ -160,4 +162,2 @@ Redis store for @mgcrea/fastify-session using ioredis

Fast sodium-based crypto for @mgcrea/fastify-session
- [`@mgcrea/fastify-session`](https://github.com/mgcrea/fastify-session) Session
plugin for Fastify that supports both stateless and stateful sessions
- [`@mgcrea/pino-pretty-compact`](https://github.com/mgcrea/pino-pretty-compact)

@@ -175,2 +175,4 @@ A custom compact pino-base prettifier

request IDs into your logs.
- [`fast-water`](https://github.com/tswayne/fast-water) A Fastify plugin for
waterline. Decorates Fastify with waterline models.
- [`fastify-405`](https://github.com/Eomm/fastify-405) Fastify plugin that adds

@@ -294,2 +296,4 @@ 405 HTTP status to your routes

Fastify plugin that exposes a GCP Cloud Storage client instance.
- [`fastify-graceful-shutdown`](https://github.com/hemerajs/fastify-graceful-shutdown)
Shutdown Fastify gracefully and asynchronously.
- [`fastify-grant`](https://github.com/simov/fastify-grant)

@@ -300,4 +304,2 @@ Authentication/Authorization plugin for Fastify that supports 200+ OAuth

that protects endpoints by checking authenticated user roles and/or scopes.
- [`fastify-graceful-shutdown`](https://github.com/hemerajs/fastify-graceful-shutdown)
Shutdown Fastify gracefully and asynchronously.
- [`fastify-hasura`](https://github.com/ManUtopiK/fastify-hasura) A Fastify

@@ -310,16 +312,15 @@ plugin to have fun with [Hasura](https://github.com/hasura/graphql-engine).

[nats.io](https://nats.io/).
- [`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).
- [`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.
- [`fastify-http-errors-enhanced`](https://github.com/ShogunPanda/fastify-http-errors-enhanced)
An error handling plugin for Fastify that uses enhanced HTTP errors.
- [`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.
- [`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).
- [`fastify-http-errors-enhanced`](https://github.com/ShogunPanda/fastify-http-errors-enhanced)
An error handling plugin for Fastify that uses enhanced HTTP errors.
- [`fastify-https-redirect`](https://github.com/tomsvogel/fastify-https-redirect)
Fastify plugin for auto-redirect from HTTP to HTTPS.
- [`fatify-impressions`](https://github.com/manju4ever/fastify-impressions)
- [`fastify-impressions`](https://github.com/manju4ever/fastify-impressions)
Fastify plugin to track impressions of all the routes.

@@ -418,6 +419,6 @@ - [`fastify-influxdb`](https://github.com/alex-ppg/fastify-influxdb) Fastify

across every part of your server.
- [`fastify-peekaboo`](https://github.com/simone-sanfratello/fastify-peekaboo)
Fastify plugin for memoize responses by expressive settings.
- [`fastify-piscina`](https://github.com/piscinajs/fastify-piscina) A worker
thread pool plugin using [Piscina](https://github.com/piscinajs/piscina).
- [`fastify-peekaboo`](https://github.com/simone-sanfratello/fastify-peekaboo)
Fastify plugin for memoize responses by expressive settings.
- [`fastify-polyglot`](https://github.com/heply/fastify-polyglot) A plugin to

@@ -455,6 +456,6 @@ handle i18n using

loaded file names by a regular expression.
- [`fastify-response-caching`](https://github.com/codeaholicguy/fastify-response-caching)
A Fastify plugin for caching the response.
- [`fastify-response-time`](https://github.com/lolo32/fastify-response-time) Add
`X-Response-Time` header at each request for Fastify, in milliseconds.
- [`fastify-response-caching`](https://github.com/codeaholicguy/fastify-response-caching)
A Fastify plugin for caching the response.
- [`fastify-resty`](https://github.com/FastifyResty/fastify-resty) Fastify-based

@@ -530,4 +531,2 @@ web framework with REST API routes auto-generation for TypeORM entities using

Application Messaging Protocol router for Fastify.
- [`fast-water`](https://github.com/tswayne/fast-water) A Fastify plugin for
waterline. Decorates Fastify with waterline models.
- [`fastify-webpack-hmr`](https://github.com/lependu/fastify-webpack-hmr)

@@ -565,2 +564,4 @@ Webpack hot module reloading plugin for Fastify.

and lightweight Sequelize plugin for Fastify.
- [`typeorm-fastify-plugin`](https://github.com/jclemens24/fastify-typeorm) A simple
and updated Typeorm plugin for use with Fastify.

@@ -570,1 +571,3 @@ #### [Community Tools](#community-tools)

generator by directory structure.
- [`simple-tjscli`](https://github.com/imjuni/simple-tjscli) CLI tool to
generate JSON Schema from TypeScript interfaces.

@@ -68,2 +68,31 @@ # V4 Migration Guide

### Synchronous route definitions
The route registration has been made synchronous from v4.
This change was done to provide better error reporting for route definition.
As a result if you specify an `onRoute` hook in a plugin you should either:
* wrap your routes in a plugin (recommended)
* use `await register(...)`
For example refactor this:
```
fastify.register((instance, opts, done) => {
instance.addHook('onRoute', (routeOptions) => {
const { path, method } = routeOptions;
console.log({ path, method });
});
done();
});
```
Into this:
```
await fastify.register((instance, opts, done) => {
instance.addHook('onRoute', (routeOptions) => {
const { path, method } = routeOptions;
console.log({ path, method });
});
done();
});
```
## Non Breaking Changes

@@ -70,0 +99,0 @@

@@ -199,2 +199,7 @@ <h1 align="center">Fastify</h1>

```
Reminder that the `this` keyword is not available on *arrow functions*,
so when passing functions in *`decorateReply`* and *`decorateRequest`* as
a utility that also needs access to the `request` and `reply` instance,
a function that is defined using the `function` keyword is needed instead
of an *arrow function expression*.

@@ -201,0 +206,0 @@ In the same way you can do this for the `request` object:

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

const server = fastify({
ajv: {
customOptions: {
strict: 'log',
keywords: ['kind', 'modifier'],
},
},
}).withTypeProvider<TypeBoxTypeProvider>()
const server = fastify().withTypeProvider<TypeBoxTypeProvider>()

@@ -98,9 +91,2 @@ server.get('/route', {

TypeBox uses the properties `kind` and `modifier` internally. These properties
are not strictly valid JSON schema which will cause `AJV@7` and newer versions
to throw an invalid schema error. To remove the error it's either necessary to
omit the properties by using
[`Type.Strict()`](https://github.com/sinclairzx81/typebox#strict) or use the AJV
options for adding custom keywords.
See also the [TypeBox

@@ -107,0 +93,0 @@ documentation](https://github.com/sinclairzx81/typebox#validation) on how to set

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

And it should return back `logged in!`
6. But wait theres more! The generic interfaces are also available inside route
6. But wait there's more! The generic interfaces are also available inside route
level hook methods. Modify the previous route by adding a `preValidation`

@@ -407,3 +407,3 @@ hook:

If you do not want to generate types from your schemas, but want to use them
diretly from your code, you can use the package
directly from your code, you can use the package
[json-schema-to-ts](https://www.npmjs.com/package/json-schema-to-ts).

@@ -666,2 +666,26 @@

Note that using `require` will not load the type definitions properly and may
cause type errors.
TypeScript can only identify the types that are directly imported into code,
which means that you can use require inline with import on top. For example:
```typescript
import 'plugin' // here will trigger the type augmentation.
fastify.register(require('plugin'))
```
```typescript
import plugin from 'plugin' // here will trigger the type augmentation.
fastify.register(plugin)
```
Or even explicit config on tsconfig
```jsonc
{
"types": ["plugin"] // we force TypeScript to import the types
}
```
## Code Completion In Vanilla JavaScript

@@ -1384,3 +1408,3 @@

It extends the Node.js `Error` type, and adds two additional, optional
properties: `statusCode: number` and `validation: ValiationResult[]`.
properties: `statusCode: number` and `validation: ValidationResult[]`.

@@ -1387,0 +1411,0 @@ ##### fastify.ValidationResult

'use strict'
const VERSION = '4.2.0'
const VERSION = '4.2.1'

@@ -5,0 +5,0 @@ const Avvio = require('avvio')

@@ -77,20 +77,20 @@ // This file is autogenerated by build/build-error-serializer.js, do not edit

asDatetime (date) {
const quotes = '"'
asDateTime (date) {
if (date === null) return '""'
if (date instanceof Date) {
return quotes + date.toISOString() + quotes
return '"' + date.toISOString() + '"'
}
return this.asString(date)
throw new Error(`The value "${date}" cannot be converted to a date-time.`)
}
asDatetimeNullable (date) {
return date === null ? 'null' : this.asDatetime(date)
asDateTimeNullable (date) {
return date === null ? 'null' : this.asDateTime(date)
}
asDate (date) {
const quotes = '"'
if (date === null) return '""'
if (date instanceof Date) {
return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(0, 10) + quotes
return '"' + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(0, 10) + '"'
}
return this.asString(date)
throw new Error(`The value "${date}" cannot be converted to a date.`)
}

@@ -103,7 +103,7 @@

asTime (date) {
const quotes = '"'
if (date === null) return '""'
if (date instanceof Date) {
return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(11, 19) + quotes
return '"' + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(11, 19) + '"'
}
return this.asString(date)
throw new Error(`The value "${date}" cannot be converted to a time.`)
}

@@ -110,0 +110,0 @@

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

key = key.toLowerCase()
if (this[kReplyHeaders][key] !== undefined) {
return true
}
return this.raw.hasHeader(key)
return this[kReplyHeaders][key] !== undefined || this.raw.hasHeader(key)
}

@@ -220,21 +218,20 @@

Reply.prototype.header = function (key, value) {
const _key = key.toLowerCase()
Reply.prototype.header = function (key, value = '') {
key = key.toLowerCase()
// default the value to ''
value = value === undefined ? '' : value
if (this[kReplyHeaders][_key] && _key === 'set-cookie') {
if (this[kReplyHeaders][key] && key === 'set-cookie') {
// https://tools.ietf.org/html/rfc7230#section-3.2.2
if (typeof this[kReplyHeaders][_key] === 'string') {
this[kReplyHeaders][_key] = [this[kReplyHeaders][_key]]
if (typeof this[kReplyHeaders][key] === 'string') {
this[kReplyHeaders][key] = [this[kReplyHeaders][key]]
}
if (Array.isArray(value)) {
Array.prototype.push.apply(this[kReplyHeaders][_key], value)
this[kReplyHeaders][key].push(...value)
} else {
this[kReplyHeaders][_key].push(value)
this[kReplyHeaders][key].push(value)
}
} else {
this[kReplyHeaders][_key] = value
this[kReplyHeaders][key] = value
}
return this

@@ -250,2 +247,3 @@ }

}
return this

@@ -285,4 +283,3 @@ }

Reply.prototype.hasTrailer = function (key) {
if (this[kReplyTrailers] === null) return false
return this[kReplyTrailers][key.toLowerCase()] !== undefined
return this[kReplyTrailers]?.[key.toLowerCase()] !== undefined
}

@@ -337,4 +334,3 @@

this.header('location', url).code(code).send()
return this
return this.header('location', url).code(code).send()
}

@@ -493,6 +489,9 @@

if (reply[kReplyTrailers] === null) {
if (!reply[kReplyHeaders]['content-length']) {
const contentLength = reply[kReplyHeaders]['content-length']
if (!contentLength ||
(req.raw.method !== 'HEAD' &&
parseInt(contentLength, 10) !== Buffer.byteLength(payload)
)
) {
reply[kReplyHeaders]['content-length'] = '' + Buffer.byteLength(payload)
} else if (req.raw.method !== 'HEAD' && reply[kReplyHeaders]['content-length'] !== Buffer.byteLength(payload)) {
reply[kReplyHeaders]['content-length'] = '' + Buffer.byteLength(payload)
}

@@ -499,0 +498,0 @@ }

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

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

"lint:typescript": "eslint -c types/.eslintrc.json types/**/*.d.ts test/types/**/*.test-d.ts",
"prepublishOnly": "tap --no-check-coverage test/build/**.test.js",
"prepublishOnly": "PREPUBLISH=true tap --no-check-coverage test/build/**.test.js",
"test": "npm run lint && npm run unit && npm run test:typescript",

@@ -130,3 +130,3 @@ "test:ci": "npm run unit -- -R terse --cov --coverage-report=lcovonly && npm run test:typescript",

"@fastify/pre-commit": "^2.0.2",
"@sinclair/typebox": "^0.23.5",
"@sinclair/typebox": "^0.24.9",
"@sinonjs/fake-timers": "^9.1.2",

@@ -152,3 +152,3 @@ "@types/node": "^18.0.0",

"fast-json-stringify": "^5.0.0",
"fastify-plugin": "^3.0.1",
"fastify-plugin": "^4.0.0",
"fluent-json-schema": "^3.1.0",

@@ -176,3 +176,3 @@ "form-data": "^4.0.0",

"tap": "^16.2.0",
"tsd": "^0.21.0",
"tsd": "^0.22.0",
"typescript": "^4.7.2",

@@ -184,3 +184,3 @@ "undici": "^5.4.0",

"dependencies": {
"@fastify/ajv-compiler": "^3.1.0",
"@fastify/ajv-compiler": "^3.1.1",
"@fastify/error": "^3.0.0",

@@ -187,0 +187,0 @@ "@fastify/fast-json-stringify-compiler": "^4.0.0",

@@ -41,14 +41,14 @@ <div align="center"> <a href="https://fastify.io/">

- [Quick start](./README.md#quick-start)
- [Install](./README.md#install)
- [Example](./README.md#example)
- [Fastify v1.x and v2.x](./README.md#fastify-v1x-and-v2x)
- [Core features](./README.md#core-features)
- [Benchmarks](./README.md#benchmarks)
- [Documentation](./README.md#documentation)
- [Ecosystem](./README.md#ecosystem)
- [Support](./README.md#support)
- [Team](./README.md#team)
- [Hosted by](./README.md#hosted-by)
- [License](./README.md#license)
- [Quick start](#quick-start)
- [Install](#install)
- [Example](#example)
- [Fastify v1.x and v2.x](#fastify-v1x-and-v2x)
- [Core features](#core-features)
- [Benchmarks](#benchmarks)
- [Documentation](#documentation)
- [Ecosystem](#ecosystem)
- [Support](#support)
- [Team](#team)
- [Hosted by](#hosted-by)
- [License](#license)

@@ -103,4 +103,3 @@ Enter Fastify. Fastify is a web framework highly focused on providing the best

If installing in an existing project, then Fastify can be installed into the
project as a dependency:
To install Fastify in an existing project as a dependency:

@@ -107,0 +106,0 @@ Install with npm:

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

test('ensure the current error serializer is latest', async (t) => {
const isPrebublish = !!process.env.PREPUBLISH
test('ensure the current error serializer is latest', { skip: !isPrebublish }, async (t) => {
t.plan(1)

@@ -29,0 +31,0 @@

@@ -7,2 +7,3 @@ 'use strict'

const AJV = require('ajv')
const Schema = require('fluent-json-schema')

@@ -950,1 +951,71 @@ const customSchemaCompilers = {

})
test("The same $id in route's schema must not overwrite others", t => {
t.plan(4)
const fastify = Fastify()
const UserSchema = Schema.object()
.id('http://mydomain.com/user')
.title('User schema')
.description('Contains all user fields')
.prop('id', Schema.integer())
.prop('username', Schema.string().minLength(4))
.prop('firstName', Schema.string().minLength(1))
.prop('lastName', Schema.string().minLength(1))
.prop('fullName', Schema.string().minLength(1))
.prop('email', Schema.string())
.prop('password', Schema.string().minLength(6))
.prop('bio', Schema.string())
const userCreateSchema = UserSchema.only([
'username',
'firstName',
'lastName',
'email',
'bio',
'password',
'password_confirm'
])
.required([
'username',
'firstName',
'lastName',
'email',
'bio',
'password'
])
const userPatchSchema = UserSchema.only([
'firstName',
'lastName',
'bio'
])
fastify
.patch('/user/:id', {
schema: { body: userPatchSchema },
handler: () => { return 'ok' }
})
.post('/user', {
schema: { body: userCreateSchema },
handler: () => { return 'ok' }
})
fastify.inject({
method: 'POST',
url: '/user',
body: {}
}, (err, res) => {
t.error(err)
t.same(res.json().message, "body must have required property 'username'")
})
fastify.inject({
url: '/user/1',
method: 'PATCH',
body: {}
}, (err, res) => {
t.error(err)
t.same(res.payload, 'ok')
})
})

@@ -197,4 +197,15 @@ import fastify, {

}))
expectAssignable<FastifyInstance>(fastify({ schemaErrorFormatter: (errors, dataVar) => new Error() }))
expectAssignable<FastifyInstance>(fastify({
schemaErrorFormatter: (errors, dataVar) => {
console.log(
errors[0].keyword.toLowerCase(),
errors[0].message?.toLowerCase(),
errors[0].params,
errors[0].instancePath.toLowerCase(),
errors[0].schemaPath.toLowerCase()
)
return new Error()
}
}))
expectAssignable<FastifyInstance>(fastify({
clientErrorHandler: (err, socket) => {

@@ -201,0 +212,0 @@ expectType<ConnectionError>(err)

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

import { DefaultRoute } from '../../types/route'
import { FastifySchemaControllerOptions } from '../../types/schema'
import { FastifySchemaControllerOptions, FastifySchemaCompiler, FastifySerializerCompiler } from '../../types/schema'

@@ -329,1 +329,4 @@ const server = fastify()

expectAssignable<DefaultRoute<RawRequestDefaultExpression, RawReplyDefaultExpression>>(server.getDefaultRoute())
expectType<FastifySchemaCompiler<any> | undefined>(server.validatorCompiler)
expectType<FastifySerializerCompiler<any> | undefined>(server.serializerCompiler)

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

test('should call custom error formatter', t => {
t.plan(6)
t.plan(9)

@@ -504,2 +504,7 @@ const fastify = Fastify({

t.equal(errors[0].message, "must have required property 'name'")
t.equal(errors[0].keyword, 'required')
t.equal(errors[0].schemaPath, '#/required')
t.same(errors[0].params, {
missingProperty: 'name'
})
t.equal(dataVar, 'body')

@@ -506,0 +511,0 @@ return new Error('my error')

@@ -1,4 +0,4 @@

import * as http from 'http'
import { FastifyError } from '@fastify/error'
import { ConstraintStrategy, HTTPVersion } from 'find-my-way'
import * as http from 'http'
import { CallbackFunc as LightMyRequestCallback, Chain as LightMyRequestChain, InjectOptions, Response as LightMyRequestResponse } from 'light-my-request'

@@ -33,2 +33,48 @@ import { AddContentTypeParser, ConstructorAction, FastifyBodyParser, getDefaultJsonParser, hasContentTypeParser, ProtoAction, removeAllContentTypeParsers, removeContentTypeParser } from './content-type-parser'

export interface FastifyListenOptions {
/**
* Default to `0` (picks the first available open port).
*/
port?: number;
/**
* Default to `localhost`.
*/
host?: string;
/**
* Will be ignored if `port` is specified.
* @see [Identifying paths for IPC connections](https://nodejs.org/api/net.html#identifying-paths-for-ipc-connections).
*/
path?: string;
/**
* Specify the maximum length of the queue of pending connections.
* The actual length will be determined by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn` on Linux.
* Default to `511`.
*/
backlog?: number;
/**
* Default to `false`.
*/
exclusive?: boolean;
/**
* For IPC servers makes the pipe readable for all users.
* Default to `false`.
*/
readableAll?: boolean;
/**
* For IPC servers makes the pipe writable for all users.
* Default to `false`.
*/
writableAll?: boolean;
/**
* For TCP servers, setting `ipv6Only` to `true` will disable dual-stack support, i.e., binding to host `::` won't make `0.0.0.0` be bound.
* Default to `false`.
*/
ipv6Only?: boolean;
/**
* An AbortSignal that may be used to close a listening server.
* @since This option is available only in Node.js v15.6.0 and greater
*/
signal?: AbortSignal;
}
type NotInInterface<Key, _Interface> = Key extends keyof _Interface ? never : Key

@@ -97,92 +143,4 @@ type FindMyWayVersion<RawServer extends RawServerBase> = RawServer extends http.Server ? HTTPVersion.V1 : HTTPVersion.V2

listen(opts: {
/**
* Default to `0` (picks the first available open port).
*/
port?: number;
/**
* Default to `localhost`.
*/
host?: string;
/**
* Will be ignored if `port` is specified.
* @see [Identifying paths for IPC connections](https://nodejs.org/api/net.html#identifying-paths-for-ipc-connections).
*/
path?: string;
/**
* Specify the maximum length of the queue of pending connections.
* The actual length will be determined by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn` on Linux.
* Default to `511`.
*/
backlog?: number;
/**
* Default to `false`.
*/
exclusive?: boolean;
/**
* For IPC servers makes the pipe readable for all users.
* Default to `false`.
*/
readableAll?: boolean;
/**
* For IPC servers makes the pipe writable for all users.
* Default to `false`.
*/
writableAll?: boolean;
/**
* For TCP servers, setting `ipv6Only` to `true` will disable dual-stack support, i.e., binding to host `::` won't make `0.0.0.0` be bound.
* Default to `false`.
*/
ipv6Only?: boolean;
/**
* An AbortSignal that may be used to close a listening server.
* @since This option is available only in Node.js v15.6.0 and greater
*/
signal?: AbortSignal;
}, callback: (err: Error|null, address: string) => void): void;
listen(opts?: {
/**
* Default to `0` (picks the first available open port).
*/
port?: number;
/**
* Default to `localhost`.
*/
host?: string;
/**
* Will be ignored if `port` is specified.
* @see [Identifying paths for IPC connections](https://nodejs.org/api/net.html#identifying-paths-for-ipc-connections).
*/
path?: string;
/**
* Specify the maximum length of the queue of pending connections.
* The actual length will be determined by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn` on Linux.
* Default to `511`.
*/
backlog?: number;
/**
* Default to `false`.
*/
exclusive?: boolean;
/**
* For IPC servers makes the pipe readable for all users.
* Default to `false`.
*/
readableAll?: boolean;
/**
* For IPC servers makes the pipe writable for all users.
* Default to `false`.
*/
writableAll?: boolean;
/**
* For TCP servers, setting `ipv6Only` to `true` will disable dual-stack support, i.e., binding to host `::` won't make `0.0.0.0` be bound.
* Default to `false`.
*/
ipv6Only?: boolean;
/**
* An AbortSignal that may be used to close a listening server.
* @since This option is available only in Node.js v15.6.0 and greater
*/
signal?: AbortSignal;
}): Promise<string>;
listen(opts: FastifyListenOptions, callback: (err: Error | null, address: string) => void): void;
listen(opts?: FastifyListenOptions): Promise<string>;
listen(callback: (err: Error | null, address: string) => void): void;

@@ -556,2 +514,7 @@

/**
* Fastify schema validator for all routes.
*/
validatorCompiler: FastifySchemaCompiler<any> | undefined;
/**
* Set the schema validator for all routes.

@@ -562,2 +525,7 @@ */

/**
* Fastify schema serializer for all routes.
*/
serializerCompiler: FastifySerializerCompiler<any> | undefined;
/**
* Set the schema serializer for all routes.

@@ -564,0 +532,0 @@ */

@@ -26,4 +26,7 @@ import { ValidatorCompiler } from '@fastify/ajv-compiler'

export interface FastifySchemaValidationError {
keyword: string;
instancePath: string;
schemaPath: string;
params: Record<string, string | string[]>;
message?: string;
instancePath: string;
}

@@ -30,0 +33,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc