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.19.1 to 4.19.2

24

fastify.js
'use strict'
const VERSION = '4.19.1'
const VERSION = '4.19.2'

@@ -429,8 +429,2 @@ const Avvio = require('avvio')

hookRunnerApplication('preClose', fastify[kAvvioBoot], fastify, function () {
// No new TCP connections are accepted.
// We must call close on the server even if we are not listening
// otherwise memory will be leaked.
// https://github.com/nodejs/node/issues/48604
instance.server.close(done)
if (fastify[kState].listening) {

@@ -454,4 +448,18 @@ /* istanbul ignore next: Cannot test this without Node.js core support */

}
}
// No new TCP connections are accepted.
// We must call close on the server even if we are not listening
// otherwise memory will be leaked.
// https://github.com/nodejs/node/issues/48604
if (!options.serverFactory || fastify[kState].listening) {
instance.server.close(function (err) {
if (err && err.code !== 'ERR_SERVER_NOT_RUNNING') {
done(null)
} else {
done()
}
})
} else {
done(null)
process.nextTick(done, null)
}

@@ -458,0 +466,0 @@ })

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

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

@@ -85,1 +85,43 @@ 'use strict'

})
test('Should not call close on the server if it has not created it', async t => {
const server = http.createServer()
const serverFactory = (handler, opts) => {
server.on('request', handler)
return server
}
const fastify = Fastify({ serverFactory })
fastify.get('/', (req, reply) => {
reply.send({ hello: 'world' })
})
await fastify.ready()
await new Promise((resolve, reject) => {
server.listen(0)
server.on('listening', resolve)
server.on('error', reject)
})
const address = server.address()
t.equal(server.listening, true)
await fastify.close()
t.equal(server.listening, true)
t.same(server.address(), address)
t.same(fastify.addresses(), [address])
await new Promise((resolve, reject) => {
server.close((err) => {
if (err) {
return reject(err)
}
resolve()
})
})
t.equal(server.listening, false)
t.same(server.address(), null)
})
import { FastifyError } from '@fastify/error'
import { expectAssignable, expectError, expectType } from 'tsd'
import fastify, {
ContextConfigDefault, FastifyContextConfig,
FastifyInstance,
FastifyPluginOptions,
FastifyReply,
FastifyRequest,
FastifySchema,
FastifyTypeProviderDefault,
RawReplyDefaultExpression,
RawRequestDefaultExpression,
RouteOptions,
RawServerDefault,
RegisterOptions,
FastifyPluginOptions,
FastifySchema,
FastifyTypeProviderDefault,
ContextConfigDefault, FastifyContextConfig, RawServerDefault
RouteOptions
} from '../../fastify'
import { preHandlerAsyncHookHandler, RequestPayload } from '../../types/hooks'
import { RouteGenericInterface } from '../../types/route'
import { ResolveFastifyRequestType } from '../../types/type-provider'
import { RequestPayload, preHandlerAsyncHookHandler } from '../../types/hooks'
import { FastifyRouteConfig, RouteGenericInterface } from '../../types/route'

@@ -255,2 +255,3 @@ const server = fastify()

}
type CustomContextConfigWithDefault = CustomContextConfig & FastifyRouteConfig

@@ -262,36 +263,36 @@ server.route<RouteGenericInterface, CustomContextConfig>({

onRequest: (request, reply, done) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preParsing: (request, reply, payload, done) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preValidation: (request, reply, done) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preHandler: (request, reply, done) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preSerialization: (request, reply, payload, done) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onSend: (request, reply, payload, done) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onResponse: (request, reply, done) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onTimeout: (request, reply, done) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onError: (request, reply, error, done) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
}

@@ -302,40 +303,40 @@ })

onRequest: async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preParsing: async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preValidation: async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preHandler: async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preSerialization: async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onSend: async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onResponse: async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onTimeout: async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onError: async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
}
}, async (request, reply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
})

@@ -350,36 +351,36 @@

onRequest: async (request: CustomContextRequest, reply: CustomContextReply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preParsing: async (request: CustomContextRequest, reply: CustomContextReply, payload: RequestPayload) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preValidation: async (request: CustomContextRequest, reply: CustomContextReply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preHandler: async (request: CustomContextRequest, reply: CustomContextReply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
preSerialization: async (request: CustomContextRequest, reply: CustomContextReply, payload: any) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onSend: async (request: CustomContextRequest, reply: CustomContextReply, payload: any) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onResponse: async (request: CustomContextRequest, reply: CustomContextReply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onTimeout: async (request: CustomContextRequest, reply: CustomContextReply) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
},
onError: async (request: CustomContextRequest, reply: CustomContextReply, error: FastifyError) => {
expectType<CustomContextConfig>(request.context.config)
expectType<CustomContextConfig>(reply.context.config)
expectType<CustomContextConfigWithDefault>(request.context.config)
expectType<CustomContextConfigWithDefault>(reply.context.config)
}

@@ -386,0 +387,0 @@ })

@@ -318,2 +318,4 @@ import { expectAssignable, expectDeprecated, expectError, expectNotDeprecated, expectType } from 'tsd'

})
server.decorate('test')
server.decorate('test', null, ['foo'])

@@ -326,2 +328,4 @@ server.decorateRequest<(x: string, y: number) => void>('test', function (x: string, y: number): void {

})
server.decorateRequest('test')
server.decorateRequest('test', null, ['foo'])

@@ -334,2 +338,4 @@ server.decorateReply<(x: string) => void>('test', function (x: string): void {

})
server.decorateReply('test')
server.decorateReply('test', null, ['foo'])

@@ -355,3 +361,16 @@ expectError(server.decorate<string>('test', true))

}
interface FastifyRequest {
typedTestRequestProperty: boolean
typedTestRequestPropertyGetterSetter: string
typedTestRequestMethod (x: string): string
}
interface FastifyReply {
typedTestReplyProperty: boolean
typedTestReplyPropertyGetterSetter: string
typedTestReplyMethod (x: string): string
}
}
server.decorate('typedTestProperty', false)

@@ -372,2 +391,5 @@ server.decorate('typedTestProperty', {

})
server.decorate('typedTestProperty')
server.decorate('typedTestProperty', null, ['foo'])
server.decorate('typedTestProperty', null)
expectError(server.decorate('typedTestProperty', 'foo'))

@@ -395,2 +417,82 @@ expectError(server.decorate('typedTestProperty', {

server.decorateRequest('typedTestRequestProperty', false)
server.decorateRequest('typedTestRequestProperty', {
getter () {
return false
}
})
server.decorateRequest('typedTestRequestProperty', {
getter (): boolean {
return true
},
setter (x) {
expectType<boolean>(x)
expectType<FastifyRequest>(this)
}
})
server.decorateRequest('typedTestRequestProperty')
server.decorateRequest('typedTestRequestProperty', null, ['foo'])
server.decorateRequest('typedTestRequestProperty', null)
expectError(server.decorateRequest('typedTestRequestProperty', 'foo'))
expectError(server.decorateRequest('typedTestRequestProperty', {
getter () {
return 'foo'
}
}))
server.decorateRequest('typedTestRequestMethod', function (x) {
expectType<string>(x)
expectType<FastifyRequest>(this)
return 'foo'
})
server.decorateRequest('typedTestRequestMethod', x => x)
expectError(server.decorateRequest('typedTestRequestMethod', function (x: boolean) {
return 'foo'
}))
expectError(server.decorateRequest('typedTestRequestMethod', function (x) {
return true
}))
expectError(server.decorateRequest('typedTestRequestMethod', async function (x) {
return 'foo'
}))
server.decorateReply('typedTestReplyProperty', false)
server.decorateReply('typedTestReplyProperty', {
getter () {
return false
}
})
server.decorateReply('typedTestReplyProperty', {
getter (): boolean {
return true
},
setter (x) {
expectType<boolean>(x)
expectType<FastifyReply>(this)
}
})
server.decorateReply('typedTestReplyProperty')
server.decorateReply('typedTestReplyProperty', null, ['foo'])
server.decorateReply('typedTestReplyProperty', null)
expectError(server.decorateReply('typedTestReplyProperty', 'foo'))
expectError(server.decorateReply('typedTestReplyProperty', {
getter () {
return 'foo'
}
}))
server.decorateReply('typedTestReplyMethod', function (x) {
expectType<string>(x)
expectType<FastifyReply>(this)
return 'foo'
})
server.decorateReply('typedTestReplyMethod', x => x)
expectError(server.decorateReply('typedTestReplyMethod', function (x: boolean) {
return 'foo'
}))
expectError(server.decorateReply('typedTestReplyMethod', function (x) {
return true
}))
expectError(server.decorateReply('typedTestReplyMethod', async function (x) {
return 'foo'
}))
const versionConstraintStrategy = {

@@ -397,0 +499,0 @@ name: 'version',

@@ -1,12 +0,12 @@

import { expectType, expectError, expectAssignable } from 'tsd'
import fastify, { RouteHandlerMethod, RouteHandler, RawRequestDefaultExpression, FastifyContext, FastifyContextConfig, FastifyRequest, FastifyReply, FastifySchema, FastifyTypeProviderDefault } from '../../fastify'
import { RawServerDefault, RawReplyDefaultExpression, ContextConfigDefault } from '../../types/utils'
import { Buffer } from 'buffer'
import { expectAssignable, expectError, expectType } from 'tsd'
import fastify, { FastifyContext, FastifyReply, FastifyRequest, FastifySchema, FastifySchemaCompiler, FastifyTypeProviderDefault, RawRequestDefaultExpression, RouteHandler, RouteHandlerMethod } from '../../fastify'
import { FastifyInstance } from '../../types/instance'
import { FastifyLoggerInstance } from '../../types/logger'
import { ResolveReplyTypeWithRouteGeneric } from '../../types/reply'
import { RouteGenericInterface } from '../../types/route'
import { FastifyInstance } from '../../types/instance'
import { Buffer } from 'buffer'
import { ReplyTypeConstrainer } from '../../types/reply'
import { ContextConfigDefault, RawReplyDefaultExpression, RawServerDefault } from '../../types/utils'
type DefaultSerializationFunction = (payload: { [key: string]: unknown }) => string
type DefaultFastifyReplyWithCode<Code extends number> = FastifyReply<RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, RouteGenericInterface, ContextConfigDefault, FastifySchema, FastifyTypeProviderDefault, ReplyTypeConstrainer<RouteGenericInterface['Reply'], Code>>
type DefaultFastifyReplyWithCode<Code extends number> = FastifyReply<RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, RouteGenericInterface, ContextConfigDefault, FastifySchema, FastifyTypeProviderDefault, ResolveReplyTypeWithRouteGeneric<RouteGenericInterface['Reply'], Code, FastifySchema, FastifyTypeProviderDefault>>

@@ -16,3 +16,3 @@ const getHandler: RouteHandlerMethod = function (_request, reply) {

expectType<FastifyContext<ContextConfigDefault>>(reply.context)
expectType<FastifyContextConfig>(reply.context.config)
expectType<FastifyContext<ContextConfigDefault>['config']>(reply.context.config)
expectType<FastifyLoggerInstance>(reply.log)

@@ -19,0 +19,0 @@ expectType<FastifyRequest<RouteGenericInterface, RawServerDefault, RawRequestDefaultExpression>>(reply.request)

@@ -0,24 +1,23 @@

import pino from 'pino'
import { expectAssignable, expectType } from 'tsd'
import pino from 'pino'
import fastify, {
RouteHandler,
ContextConfigDefault,
FastifyContext,
FastifyLogFn,
FastifySchema,
FastifyTypeProviderDefault,
RawReplyDefaultExpression,
RawRequestDefaultExpression,
RawServerDefault,
RequestBodyDefault,
RequestGenericInterface,
FastifyContext,
ContextConfigDefault,
FastifyContextConfig,
FastifyLogFn,
RouteHandlerMethod,
RawServerDefault,
RawReplyDefaultExpression,
FastifySchema,
FastifyTypeProviderDefault
RouteHandler,
RouteHandlerMethod
} from '../../fastify'
import { RequestParamsDefault, RequestHeadersDefault, RequestQuerystringDefault } from '../../types/utils'
import { FastifyInstance } from '../../types/instance'
import { FastifyLoggerInstance } from '../../types/logger'
import { FastifyReply } from '../../types/reply'
import { FastifyRequest, RequestRouteOptions } from '../../types/request'
import { FastifyReply } from '../../types/reply'
import { FastifyInstance } from '../../types/instance'
import { RouteGenericInterface } from '../../types/route'
import { RequestHeadersDefault, RequestParamsDefault, RequestQuerystringDefault } from '../../types/utils'

@@ -79,4 +78,4 @@ interface RequestBody {

expectType<FastifyContext<ContextConfigDefault>>(request.context)
expectType<FastifyContextConfig>(request.context.config)
expectType<FastifyContextConfig>(request.routeConfig)
expectType<FastifyContext<ContextConfigDefault>['config']>(request.context.config)
expectType<FastifyContext<ContextConfigDefault>['config']>(request.routeConfig)
expectType<FastifySchema>(request.routeSchema)

@@ -114,3 +113,3 @@

expectType<FastifyContext<ContextConfigDefault>>(request.context)
expectType<FastifyContextConfig>(request.context.config)
expectType<FastifyContext<ContextConfigDefault>['config']>(request.context.config)
}

@@ -133,3 +132,3 @@

expectType<FastifyContext<ContextConfigDefault>>(request.context)
expectType<FastifyContextConfig>(request.context.config)
expectType<FastifyContext<ContextConfigDefault>['config']>(request.context.config)
}

@@ -136,0 +135,0 @@

@@ -1,7 +0,7 @@

import fastify, { FastifyInstance, FastifyRequest, FastifyReply, RouteHandlerMethod } from '../../fastify'
import { expectType, expectError, expectAssignable, printType } from 'tsd'
import { HTTPMethods } from '../../types/utils'
import { FastifyError } from '@fastify/error'
import * as http from 'http'
import { expectAssignable, expectError, expectType } from 'tsd'
import fastify, { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from '../../fastify'
import { RequestPayload } from '../../types/hooks'
import { FastifyError } from '@fastify/error'
import { HTTPMethods } from '../../types/utils'

@@ -77,3 +77,3 @@ /*

fastify()[lowerCaseMethod]<RouteGeneric, RouteSpecificContextConfigType>('/', { config: { foo: 'bar', bar: 100, extra: true, url: '/', method: lowerCaseMethod } }, (req, res) => {
fastify()[lowerCaseMethod]<RouteGeneric, RouteSpecificContextConfigType>('/', { config: { foo: 'bar', bar: 100, extra: true } }, (req, res) => {
expectType<BodyInterface>(req.body)

@@ -98,3 +98,3 @@ expectType<QuerystringInterface>(req.query)

method: method as HTTPMethods,
config: { foo: 'bar', bar: 100, url: '/', method: method as HTTPMethods },
config: { foo: 'bar', bar: 100 },
prefixTrailingSlash: 'slash',

@@ -236,3 +236,3 @@ onRequest: (req, res, done) => { // these handlers are tested in `hooks.test-d.ts`

method: method as HTTPMethods,
config: { foo: 'bar', bar: 100, url: '/', method: method as HTTPMethods },
config: { foo: 'bar', bar: 100 },
prefixTrailingSlash: 'slash',

@@ -239,0 +239,0 @@ onRequest: async (req, res, done) => { // these handlers are tested in `hooks.test-d.ts`

@@ -302,2 +302,4 @@ import fastify, {

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

@@ -531,2 +533,4 @@ ))

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

@@ -533,0 +537,0 @@ ))

@@ -0,6 +1,6 @@

import { FastifyRouteConfig } from './route'
import { ContextConfigDefault } from './utils'
import { FastifyRouteConfig } from './route'
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface FastifyContextConfig extends FastifyRouteConfig {
export interface FastifyContextConfig {
}

@@ -15,3 +15,3 @@

*/
config: FastifyContextConfig & ContextConfig;
config: FastifyContextConfig & FastifyRouteConfig & ContextConfig;
}

@@ -106,2 +106,8 @@ import { FastifyError } from '@fastify/error'

): Return;
(property: string | symbol): Return;
(property: string | symbol, value: null): Return;
(property: string | symbol, value: null|undefined, dependencies: string[]): Return;
}

@@ -108,0 +114,0 @@

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

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

@@ -16,3 +16,3 @@ export interface ReplyGenericInterface {

export type ReplyTypeConstrainer<RouteGenericReply, Code extends ReplyKeysToCodes<keyof RouteGenericReply>, ReplyKey = CodeToReplyKey<Code>> =
type ReplyTypeConstrainer<RouteGenericReply, Code extends ReplyKeysToCodes<keyof RouteGenericReply>, ReplyKey = CodeToReplyKey<Code>> =
Code extends keyof RouteGenericReply ? RouteGenericReply[Code] :

@@ -22,2 +22,7 @@ [ReplyKey] extends [never] ? unknown :

unknown;
export type ResolveReplyTypeWithRouteGeneric<RouteGenericReply, Code extends ReplyKeysToCodes<keyof RouteGenericReply>,
SchemaCompiler extends FastifySchema = FastifySchema,
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault> =
ResolveFastifyReplyType<TypeProvider, SchemaCompiler, { Reply: ReplyTypeConstrainer<RouteGenericReply, Code> }>
/**

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

server: FastifyInstance;
code<Code extends ReplyKeysToCodes<keyof RouteGeneric['Reply']>>(statusCode: Code): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, ReplyTypeConstrainer<RouteGeneric['Reply'], Code>>;
status<Code extends ReplyKeysToCodes<keyof RouteGeneric['Reply']>>(statusCode: Code): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, ReplyTypeConstrainer<RouteGeneric['Reply'], Code>>;
code<Code extends ReplyKeysToCodes<keyof RouteGeneric['Reply']>>(statusCode: Code): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, ResolveReplyTypeWithRouteGeneric<RouteGeneric['Reply'], Code, SchemaCompiler, TypeProvider>>;
status<Code extends ReplyKeysToCodes<keyof RouteGeneric['Reply']>>(statusCode: Code): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, ResolveReplyTypeWithRouteGeneric<RouteGeneric['Reply'], Code, SchemaCompiler, TypeProvider>>;
statusCode: number;

@@ -46,0 +51,0 @@ sent: boolean;

import { ErrorObject } from '@fastify/ajv-compiler'
import { FastifyContext } from './context'
import { FastifyInstance } from './instance'
import { FastifyBaseLogger } from './logger'
import { ContextConfigDefault, RawServerBase, RawServerDefault, RawRequestDefaultExpression, RequestBodyDefault, RequestQuerystringDefault, RequestParamsDefault, RequestHeadersDefault } from './utils'
import { RouteGenericInterface } from './route'
import { FastifyInstance } from './instance'
import { FastifyTypeProvider, FastifyTypeProviderDefault, FastifyRequestType, ResolveFastifyRequestType } from './type-provider'
import { FastifySchema } from './schema'
import { FastifyContext, FastifyContextConfig } from './context'
import { FastifyRequestType, FastifyTypeProvider, FastifyTypeProviderDefault, ResolveFastifyRequestType } from './type-provider'
import { ContextConfigDefault, RawRequestDefaultExpression, RawServerBase, RawServerDefault, RequestBodyDefault, RequestHeadersDefault, RequestParamsDefault, RequestQuerystringDefault } from './utils'

@@ -62,3 +62,3 @@ type HTTPRequestPart = 'body' | 'query' | 'querystring' | 'params' | 'headers'

context: FastifyContext<ContextConfig>;
routeConfig: FastifyContextConfig & ContextConfig;
routeConfig: FastifyContext<ContextConfig>['config'];
routeSchema: FastifySchema

@@ -65,0 +65,0 @@

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

import { FastifyError } from '@fastify/error'
import { FastifyContext } from './context'
import { onErrorHookHandler, onRequestAbortHookHandler, onRequestHookHandler, onResponseHookHandler, onSendHookHandler, onTimeoutHookHandler, preHandlerHookHandler, preParsingHookHandler, preSerializationHookHandler, preValidationHookHandler } from './hooks'
import { FastifyInstance } from './instance'
import { FastifyBaseLogger, LogLevel } from './logger'
import { FastifyReply, ReplyGenericInterface } from './reply'
import { FastifyRequest, RequestGenericInterface } from './request'
import { FastifyReply, ReplyGenericInterface } from './reply'
import { FastifySchema, FastifySchemaCompiler, FastifySerializerCompiler, SchemaErrorFormatter } from './schema'
import { HTTPMethods, RawServerBase, RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, ContextConfigDefault } from './utils'
import { preValidationHookHandler, preHandlerHookHandler, preSerializationHookHandler, onRequestHookHandler, preParsingHookHandler, onResponseHookHandler, onSendHookHandler, onErrorHookHandler, onTimeoutHookHandler, onRequestAbortHookHandler } from './hooks'
import { FastifyError } from '@fastify/error'
import { FastifyContext } from './context'
import {

@@ -14,3 +14,3 @@ FastifyTypeProvider,

} from './type-provider'
import { FastifyBaseLogger, LogLevel } from './logger'
import { ContextConfigDefault, HTTPMethods, RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerBase, RawServerDefault } from './utils'

@@ -45,3 +45,3 @@ export interface FastifyRouteConfig {

logLevel?: LogLevel;
config?: FastifyContext<ContextConfig>['config'];
config?: Omit<FastifyContext<ContextConfig>['config'], 'url' | 'method'>;
version?: string;

@@ -48,0 +48,0 @@ constraints?: { [name: string]: any },

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