import * as http from 'http' import * as http2 from 'http2' import * as https from 'https' import * as LightMyRequest from 'light-my-request' import { FastifyRequest } from './types/request' import { RawServerBase, RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression } from './types/utils' import { FastifyLoggerOptions } from './types/logger' import { FastifyInstance } from './types/instance' import { FastifyServerFactory } from './types/serverFactory' /** * Fastify factor function for the standard fastify http, https, or http2 server instance. * * The default function utilizes http * * @param opts Fastify server options * @returns Fastify server instance */ declare function fastify< Server extends http2.Http2SecureServer, Request extends RawRequestDefaultExpression = RawRequestDefaultExpression, Reply extends RawReplyDefaultExpression = RawReplyDefaultExpression, Logger = FastifyLoggerOptions, >(opts: FastifyHttp2SecureOptions): FastifyInstance declare function fastify< Server extends http2.Http2Server, Request extends RawRequestDefaultExpression = RawRequestDefaultExpression, Reply extends RawReplyDefaultExpression = RawReplyDefaultExpression, Logger = FastifyLoggerOptions, >(opts: FastifyHttp2Options): FastifyInstance declare function fastify< Server extends https.Server, Request extends RawRequestDefaultExpression = RawRequestDefaultExpression, Reply extends RawReplyDefaultExpression = RawReplyDefaultExpression, Logger = FastifyLoggerOptions, >(opts: FastifyHttpsOptions): FastifyInstance declare function fastify< Server extends http.Server, Request extends RawRequestDefaultExpression = RawRequestDefaultExpression, Reply extends RawReplyDefaultExpression = RawReplyDefaultExpression, Logger = FastifyLoggerOptions, >(opts?: FastifyServerOptions): FastifyInstance export default fastify type FastifyHttp2SecureOptions< Server extends http2.Http2SecureServer, Logger > = FastifyServerOptions & { http2: true, https: http2.SecureServerOptions } type FastifyHttp2Options< Server extends http2.Http2Server, Logger > = FastifyServerOptions & { http2: true } type FastifyHttpsOptions< Server extends https.Server, Logger > = FastifyServerOptions & { https: https.ServerOptions } /** * Options for a fastify server instance. Utilizes conditional logic on the generic server parameter to enforce certain https and http2 */ export type FastifyServerOptions< RawServer extends RawServerBase = RawServerDefault, Logger = FastifyLoggerOptions > = { ignoreTrailingSlash?: boolean, connectionTimeout?: number, keepAliveTimeout?: number, bodyLimit?: number, pluginTimeout?: number, onProtoPoisoing?: 'error' | 'remove' | 'ignore', logger?: boolean | Logger, serverFactory?: FastifyServerFactory, caseSensitive?: boolean, requestIdHeader?: string, genReqId?: (req: FastifyRequest>) => string, trustProxy?: boolean | string | string[] | number | TrustProxyFunction, querystringParser?: (str: string) => { [key: string]: string | string[] }, versioning?: { storage(): { get(version: string): Function | null, set(version: string, store: Function): void del(version: string): void, empty(): void }, deriveVersion(req: Object, ctx?: Context): string // not a fan of using Object here. Also what is Context? Can either of these be better defined? } } type TrustProxyFunction = (address: string, hop: number) => boolean /* Export all additional types */ export { FastifyRequest, FastifyRequestInterface, RequestGenericInterface } from './types/request' export { FastifyReply, FastifyReplyInterface } from './types/reply' export { FastifyPlugin, FastifyPluginOptions } from './types/plugin' export { FastifyInstance } from './types/instance' export { FastifyLoggerOptions, FastifyLogFn, LogLevels } from './types/logger' export { FastifyContext } from './types/context' export { RouteHandlerMethod, RouteOptions, RouteShorthandMethod, RouteShorthandOptions, RouteShorthandOptionsWithHandler } from './types/route' export * from './types/register' export { FastifyBodyParser, FastifyContentTypeParser, AddContentTypeParser, hasContentTypeParser } from './types/content-type-parser' export { FastifyError, ValidationResult } from './types/error' export { FastifySchema, FastifySchemaCompiler } from './types/schema' export { HTTPMethods, RawServerBase, RawRequestDefaultExpression, RawReplyDefaultExpression, RawServerDefault, ContextConfigDefault, RequestBodyDefault, RequestQuerystringDefault, RequestParamsDefault, RequestHeadersDefault } from './types/utils' export * from './types/hooks' export { FastifyServerFactory, FastifyServerFactoryHandler } from './types/serverFactory' export { fastify }