Socket
Socket
Sign inDemoInstall

fastify

Package Overview
Dependencies
46
Maintainers
3
Versions
282
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.29.0 to 3.29.1

78

docs/Guides/Ecosystem.md

@@ -11,9 +11,9 @@ <h1 align="center">Fastify</h1>

- [`fastify-accepts`](https://github.com/fastify/fastify-accepts) to have
- [`@fastify/accepts`](https://github.com/fastify/fastify-accepts) to have
[accepts](https://www.npmjs.com/package/accepts) in your request object.
- [`fastify-accepts-serializer`](https://github.com/fastify/fastify-accepts-serializer)
- [`@fastify/accepts-serializer`](https://github.com/fastify/fastify-accepts-serializer)
to serialize to output according to `Accept` header.
- [`fastify-auth`](https://github.com/fastify/fastify-auth) Run multiple auth
- [`@fastify/auth`](https://github.com/fastify/fastify-auth) Run multiple auth
functions in Fastify.
- [`fastify-autoload`](https://github.com/fastify/fastify-autoload) Require all
- [`@fastify/autoload`](https://github.com/fastify/fastify-autoload) Require all
plugins in a directory.

@@ -23,17 +23,17 @@ - [`fastify-awilix`](https://github.com/fastify/fastify-awilix) Dependency

[awilix](https://github.com/jeffijoe/awilix).
- [`fastify-bankai`](https://github.com/fastify/fastify-bankai)
- [`@fastify/bankai`](https://github.com/fastify/fastify-bankai)
[Bankai](https://github.com/yoshuawuyts/bankai) assets compiler for Fastify.
- [`fastify-basic-auth`](https://github.com/fastify/fastify-basic-auth) Basic
- [`@fastify/basic-auth`](https://github.com/fastify/fastify-basic-auth) Basic
auth plugin for Fastify.
- [`fastify-bearer-auth`](https://github.com/fastify/fastify-bearer-auth) Bearer
- [`@fastify/bearer-auth`](https://github.com/fastify/fastify-bearer-auth) Bearer
auth plugin for Fastify.
- [`fastify-caching`](https://github.com/fastify/fastify-caching) General
- [`@fastify/caching`](https://github.com/fastify/fastify-caching) General
server-side cache and ETag support.
- [`fastify-circuit-breaker`](https://github.com/fastify/fastify-circuit-breaker)
- [`@fastify/circuit-breaker`](https://github.com/fastify/fastify-circuit-breaker)
A low overhead circuit breaker for your routes.
- [`fastify-compress`](https://github.com/fastify/fastify-compress) Fastify
- [`@fastify/compress`](https://github.com/fastify/fastify-compress) Fastify
compression utils.
- [`fastify-cookie`](https://github.com/fastify/fastify-cookie) Parse and set
- [`@fastify/cookie`](https://github.com/fastify/fastify-cookie) Parse and set
cookie headers.
- [`fastify-cors`](https://github.com/fastify/fastify-cors) Enables the use of
- [`@fastify/cors`](https://github.com/fastify/fastify-cors) Enables the use of
CORS in a Fastify application.

@@ -43,39 +43,39 @@ - [`fastify-csrf`](https://github.com/fastify/fastify-csrf) A plugin for adding

Fastify.
- [`fastify-diagnostics-channel`](https://github.com/fastify/fastify-diagnostics-channel)
- [`@fastify/diagnostics-channel`](https://github.com/fastify/fastify-diagnostics-channel)
Plugin to deal with `diagnostics_channel` on Fastify
- [`fastify-elasticsearch`](https://github.com/fastify/fastify-elasticsearch)
- [`@fastify/elasticsearch`](https://github.com/fastify/fastify-elasticsearch)
Plugin to share the same ES client.
- [`fastify-env`](https://github.com/fastify/fastify-env) Load and check
- [`@fastify/env`](https://github.com/fastify/fastify-env) Load and check
configuration.
- [`fastify-etag`](https://github.com/fastify/fastify-etag) Automatically
- [`@fastify/etag`](https://github.com/fastify/fastify-etag) Automatically
generate ETags for HTTP responses.
- [`fastify-flash`](https://github.com/fastify/fastify-flash) Set and get flash
- [`@fastify/flash`](https://github.com/fastify/fastify-flash) Set and get flash
messages using the session.
- [`fastify-formbody`](https://github.com/fastify/fastify-formbody) Plugin to
- [`@fastify/formbody`](https://github.com/fastify/fastify-formbody) Plugin to
parse x-www-form-urlencoded bodies.
- [`fastify-funky`](https://github.com/fastify/fastify-funky) Makes functional
- [`@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.
- [`fastify-helmet`](https://github.com/fastify/fastify-helmet) Important
- [`@fastify/helmet`](https://github.com/fastify/fastify-helmet) Important
security headers for Fastify.
- [`fastify-http-proxy`](https://github.com/fastify/fastify-http-proxy) Proxy
- [`@fastify/http-proxy`](https://github.com/fastify/fastify-http-proxy) Proxy
your HTTP requests to another server, with hooks.
- [`fastify-jwt`](https://github.com/fastify/fastify-jwt) JWT utils for Fastify,
- [`@fastify/jwt`](https://github.com/fastify/fastify-jwt) JWT utils for Fastify,
internally uses [fast-jwt](https://github.com/nearform/fast-jwt).
- [`fastify-leveldb`](https://github.com/fastify/fastify-leveldb) Plugin to
- [`@fastify/leveldb`](https://github.com/fastify/fastify-leveldb) Plugin to
share a common LevelDB connection across Fastify.
- [`fastify-mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
- [`@fastify/mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
MongoDB connection plugin, with which you can share the same MongoDB
connection pool across every part of your server.
- [`fastify-multipart`](https://github.com/fastify/fastify-multipart) Multipart
- [`@fastify/multipart`](https://github.com/fastify/fastify-multipart) Multipart
support for Fastify.
- [`fastify-oauth2`](https://github.com/fastify/fastify-oauth2) Wrap around
- [`@fastify/oauth2`](https://github.com/fastify/fastify-oauth2) Wrap around
[`simple-oauth2`](https://github.com/lelylan/simple-oauth2).
- [`fastify-postgres`](https://github.com/fastify/fastify-postgres) Fastify
- [`@fastify/postgres`](https://github.com/fastify/fastify-postgres) Fastify
PostgreSQL connection plugin, with this you can share the same PostgreSQL
connection pool in every part of your server.
- [`fastify-rate-limit`](https://github.com/fastify/fastify-rate-limit) A low
- [`@fastify/rate-limit`](https://github.com/fastify/fastify-rate-limit) A low
overhead rate limiter for your routes.
- [`fastify-request-context`](https://github.com/fastify/fastify-request-context)
- [`@fastify/request-context`](https://github.com/fastify/fastify-request-context)
Request-scoped storage, based on

@@ -85,13 +85,13 @@ [AsyncLocalStorage](https://nodejs.org/api/async_hooks.html#async_hooks_class_asynclocalstorage)

providing functionality similar to thread-local storages.
- [`fastify-response-validation`](https://github.com/fastify/fastify-response-validation)
- [`@fastify/response-validation`](https://github.com/fastify/fastify-response-validation)
A simple plugin that enables response validation for Fastify.
- [`fastify-nextjs`](https://github.com/fastify/fastify-nextjs) React
- [`@fastify/nextjs`](https://github.com/fastify/fastify-nextjs) React
server-side rendering support for Fastify with
[Next](https://github.com/zeit/next.js/).
- [`fastify-redis`](https://github.com/fastify/fastify-redis) Fastify Redis
- [`@fastify/redis`](https://github.com/fastify/fastify-redis) Fastify Redis
connection plugin, with which you can share the same Redis connection across
every part of your server.
- [`fastify-reply-from`](https://github.com/fastify/fastify-reply-from) Plugin
- [`@fastify/reply-from`](https://github.com/fastify/fastify-reply-from) Plugin
to forward the current HTTP request to another server.
- [`fastify-routes`](https://github.com/fastify/fastify-routes) Plugin that
- [`@fastify/routes`](https://github.com/fastify/fastify-routes) Plugin that
provides a `Map` of routes.

@@ -101,3 +101,3 @@ - [`fastify-schedule`](https://github.com/fastify/fastify-schedule) Plugin for

[toad-scheduler](https://github.com/kibertoad/toad-scheduler).
- [`fastify-sensible`](https://github.com/fastify/fastify-sensible) Defaults for
- [`@fastify/sensible`](https://github.com/fastify/fastify-sensible) Defaults for
Fastify that everyone can agree on. It adds some useful decorators such as

@@ -107,10 +107,10 @@ HTTP errors and assertions, but also more request and reply methods.

Fastify.
- [`fastify-static`](https://github.com/fastify/fastify-static) Plugin for
- [`@fastify/static`](https://github.com/fastify/fastify-static) Plugin for
serving static files as fast as possible.
- [`fastify-swagger`](https://github.com/fastify/fastify-swagger) Plugin for
- [`@fastify/swagger`](https://github.com/fastify/fastify-swagger) Plugin for
serving Swagger/OpenAPI documentation for Fastify, supporting dynamic
generation.
- [`fastify-websocket`](https://github.com/fastify/fastify-websocket) WebSocket
- [`@fastify/websocket`](https://github.com/fastify/fastify-websocket) WebSocket
support for Fastify. Built upon [ws](https://github.com/websockets/ws).
- [`fastify-url-data`](https://github.com/fastify/fastify-url-data) Decorate the
- [`@fastify/url-data`](https://github.com/fastify/fastify-url-data) Decorate the
`Request` object with a method to access raw URL components.

@@ -117,0 +117,0 @@ - [`middie`](https://github.com/fastify/middie) Middleware engine for Fastify.

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

First, install `fastify-plugin` and `fastify-mongodb`:
First, install `fastify-plugin` and `@fastify/mongodb`:
```
npm i --save fastify-plugin fastify-mongodb
npm i --save fastify-plugin @fastify/mongodb
```

@@ -250,3 +250,3 @@

import fastifyPlugin from 'fastify-plugin'
import fastifyMongo from 'fastify-mongodb'
import fastifyMongo from '@fastify/mongodb'

@@ -270,3 +270,3 @@ async function dbConnector (fastify, options) {

async function dbConnector (fastify, options) {
fastify.register(require('fastify-mongodb'), {
fastify.register(require('@fastify/mongodb'), {
url: 'mongodb://localhost:27017/test_database'

@@ -273,0 +273,0 @@ })

@@ -17,3 +17,3 @@ # V3 Migration Guide

If you use Express middleware in your application, please install and register
the [`fastify-express`](https://github.com/fastify/fastify-express) or
the [`@fastify/express`](https://github.com/fastify/fastify-express) or
[`middie`](https://github.com/fastify/middie) plugin before doing so.

@@ -32,3 +32,3 @@

// Using the Express `cors` middleware in Fastify v3.
await fastify.register(require('fastify-express'));
await fastify.register(require('@fastify/express'));
fastify.use(require('cors')());

@@ -35,0 +35,0 @@ ```

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

error objects across your codebase and plugins with the
[`fastify-error`](https://github.com/fastify/fastify-error) module.
[`@fastify/error`](https://github.com/fastify/fastify-error) module.
```js
const createError = require('fastify-error')
const createError = require('@fastify/error')
const CustomError = createError('ERROR_CODE', 'message')

@@ -481,8 +481,8 @@ console.log(new CustomError())

rendering (*ejs, pug, handlebars, marko*) plugin support for Fastify.
- [`fastify-mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
- [`@fastify/mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
MongoDB connection plugin, with this you can share the same MongoDB connection
pool in every part of your server.
- [`fastify-multipart`](https://github.com/fastify/fastify-multipart) Multipart
- [`@fastify/multipart`](https://github.com/fastify/fastify-multipart) Multipart
support for Fastify
- [`fastify-helmet`](https://github.com/fastify/fastify-helmet) Important
- [`@fastify/helmet`](https://github.com/fastify/fastify-helmet) Important
security headers for Fastify

@@ -489,0 +489,0 @@

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

at:
- [`fastify-caching`](https://github.com/fastify/fastify-caching)
- [`fastify-compress`](https://github.com/fastify/fastify-compress)
- [`fastify-cookie`](https://github.com/fastify/fastify-cookie)
- [`@fastify/caching`](https://github.com/fastify/fastify-caching)
- [`@fastify/compress`](https://github.com/fastify/fastify-compress)
- [`@fastify/cookie`](https://github.com/fastify/fastify-cookie)
- [`point-of-view`](https://github.com/fastify/point-of-view)

@@ -97,8 +97,8 @@ - [`under-pressure`](https://github.com/fastify/under-pressure)

rendering (*ejs, pug, handlebars, marko*) plugin support for Fastify.
- [`fastify-mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
- [`@fastify/mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
MongoDB connection plugin, with this you can share the same MongoDB connection
pool in every part of your server.
- [`fastify-multipart`](https://github.com/fastify/fastify-multipart) Multipart
- [`@fastify/multipart`](https://github.com/fastify/fastify-multipart) Multipart
support for Fastify.
- [`fastify-helmet`](https://github.com/fastify/fastify-helmet) Important
- [`@fastify/helmet`](https://github.com/fastify/fastify-helmet) Important
security headers for Fastify.

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

access to the same context as the second route. Using
[fastify-bearer-auth][bearer] to provide the authentication, the code for this
[@fastify/bearer-auth][bearer] to provide the authentication, the code for this
example is as follows:

@@ -48,3 +48,3 @@

fastify.register(async function authenticatedContext (childServer) {
childServer.register(require('fastify-bearer-auth'), { keys: ['abc123'] })
childServer.register(require('@fastify/bearer-auth'), { keys: ['abc123'] })

@@ -108,3 +108,3 @@ childServer.route({

the _root context_.
2. Only the `authenticatedContext` has access to the `fastify-bearer-auth`
2. Only the `authenticatedContext` has access to the `@fastify/bearer-auth`
plugin.

@@ -111,0 +111,0 @@ 3. Both the `publicContext` and `grandchildContext` have access to the `foo`

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

fastify.addHook('preHandler', async (request, reply) => {
// the fastify-static plugin will send a file asynchronously,
// the @fastify/static plugin will send a file asynchronously,
// so we should return reply

@@ -357,0 +357,0 @@ reply.sendFile('myfile')

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

requires an external plugin such as
[`fastify-express`](https://github.com/fastify/fastify-express) or
[`@fastify/express`](https://github.com/fastify/fastify-express) or
[`middie`](https://github.com/fastify/middie).

@@ -13,7 +13,7 @@

An example of registering the
[`fastify-express`](https://github.com/fastify/fastify-express) plugin to `use`
[`@fastify/express`](https://github.com/fastify/fastify-express) plugin to `use`
Express middleware:
```js
await fastify.register(require('fastify-express'))
await fastify.register(require('@fastify/express'))
fastify.use(require('cors')())

@@ -75,7 +75,7 @@ fastify.use(require('dns-prefetch-control')())

Fastify offers some alternatives to the most commonly used middleware, such as
[`fastify-helmet`](https://github.com/fastify/fastify-helmet) in case of
[`@fastify/helmet`](https://github.com/fastify/fastify-helmet) in case of
[`helmet`](https://github.com/helmetjs/helmet),
[`fastify-cors`](https://github.com/fastify/fastify-cors) for
[`@fastify/cors`](https://github.com/fastify/fastify-cors) for
[`cors`](https://github.com/expressjs/cors), and
[`fastify-static`](https://github.com/fastify/fastify-static) for
[`@fastify/static`](https://github.com/fastify/fastify-static) for
[`serve-static`](https://github.com/expressjs/serve-static).

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

[`http-errors`](https://npm.im/http-errors) module or
[`fastify-sensible`](https://github.com/fastify/fastify-sensible) plugin to
[`@fastify/sensible`](https://github.com/fastify/fastify-sensible) plugin to
generate errors:

@@ -489,0 +489,0 @@

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

out
[fastify-swagger](https://github.com/fastify/fastify-swagger/blob/master/index.d.ts).
[@fastify/swagger](https://github.com/fastify/fastify-swagger/blob/master/index.d.ts).

@@ -610,0 +610,0 @@ With those files completed, the plugin is now ready to be consumed by any

'use strict'
const VERSION = '3.29.0'
const VERSION = '3.29.1'

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

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

if (err != null) {
if (res.headersSent) {
if (res.headersSent || reply.request.raw.aborted === true) {
if (!errorLogged) {

@@ -551,0 +551,0 @@ errorLogged = true

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

@@ -5,0 +5,0 @@ "main": "fastify.js",

@@ -686,1 +686,49 @@ 'use strict'

})
test('reply.send handles aborted requests', t => {
t.plan(2)
const spyLogger = {
level: 'error',
fatal: () => { },
error: () => {
t.fail('should not log an error')
},
warn: () => { },
info: () => { },
debug: () => { },
trace: () => { },
child: () => { return spyLogger }
}
const fastify = Fastify({
logger: spyLogger
})
fastify.get('/', (req, reply) => {
setTimeout(() => {
const stream = new Readable({
read: function () {
this.push(null)
}
})
reply.send(stream)
}, 6)
})
fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
const port = fastify.server.address().port
const http = require('http')
const req = http.get(`http://localhost:${port}`)
.on('error', (err) => {
t.equal(err.code, 'ECONNRESET')
fastify.close()
})
setTimeout(() => {
req.abort()
}, 1)
})
})

@@ -1,2 +0,2 @@

import { expectType } from 'tsd'
import { expectError, expectType } from 'tsd'
import fastify, { FastifyLogFn, LogLevel, FastifyLoggerInstance, FastifyError, FastifyRequest, FastifyReply } from '../../fastify'

@@ -186,1 +186,13 @@ import { Server, IncomingMessage, ServerResponse } from 'http'

})
const childParent = fastify().log
// we test different option variant here
expectType<FastifyLoggerInstance>(childParent.child({}, { level: 'info' }))
expectType<FastifyLoggerInstance>(childParent.child({}, { redact: ['pass', 'pin'] }))
expectType<FastifyLoggerInstance>(childParent.child({}, { serializers: { key: () => {} } }))
expectType<FastifyLoggerInstance>(childParent.child({}, { level: 'info', redact: ['pass', 'pin'], serializers: { key: () => {} } }))
// no option pass
expectError(childParent.child())
// wrong option
expectError(childParent.child({}, { nonExist: true }))

@@ -39,2 +39,7 @@ /*

export interface redactOptions {
paths: string[];
censor?: string | ((v: any) => any) | undefined;
remove?: boolean | undefined;
}
export interface Bindings {

@@ -46,2 +51,8 @@ level?: LogLevel | string;

export interface ChildLoggerOptions {
level?: LogLevel | string;
redact?: string[] | redactOptions | undefined;
serializers?: { [key: string]: SerializerFn } | undefined;
}
export interface FastifyLoggerInstance {

@@ -54,3 +65,3 @@ info: FastifyLogFn;

debug: FastifyLogFn;
child(bindings: Bindings): FastifyLoggerInstance;
child(bindings: Bindings, options?: ChildLoggerOptions): FastifyLoggerInstance;
}

@@ -57,0 +68,0 @@

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