diff --git a/packages/platform-fastify/adapters/fastify-adapter.ts b/packages/platform-fastify/adapters/fastify-adapter.ts index 57ebb70e209..837eb09e0c5 100644 --- a/packages/platform-fastify/adapters/fastify-adapter.ts +++ b/packages/platform-fastify/adapters/fastify-adapter.ts @@ -58,10 +58,17 @@ import { FastifyViewOptions, } from '../interfaces/external'; +type FastifyAdapterBaseOptions< + Server extends RawServerBase = RawServerDefault, + Logger extends FastifyBaseLogger = FastifyBaseLogger, +> = FastifyServerOptions & { + skipMiddie?: boolean; +}; + type FastifyHttp2SecureOptions< Server extends http2.Http2SecureServer, Logger extends FastifyBaseLogger = FastifyBaseLogger, -> = FastifyServerOptions & { +> = FastifyAdapterBaseOptions & { http2: true; https: http2.SecureServerOptions; }; @@ -69,7 +76,7 @@ type FastifyHttp2SecureOptions< type FastifyHttp2Options< Server extends http2.Http2Server, Logger extends FastifyBaseLogger = FastifyBaseLogger, -> = FastifyServerOptions & { +> = FastifyAdapterBaseOptions & { http2: true; http2SessionTimeout?: number; }; @@ -77,7 +84,7 @@ type FastifyHttp2Options< type FastifyHttpsOptions< Server extends https.Server, Logger extends FastifyBaseLogger = FastifyBaseLogger, -> = FastifyServerOptions & { +> = FastifyAdapterBaseOptions & { https: https.ServerOptions; }; @@ -210,7 +217,7 @@ export class FastifyAdapter< | FastifyHttp2Options | FastifyHttp2SecureOptions | FastifyHttpsOptions - | FastifyServerOptions, + | FastifyAdapterBaseOptions, ) { super(); @@ -223,7 +230,12 @@ export class FastifyAdapter< }, ...(instanceOrOptions as FastifyServerOptions), }); + this.setInstance(instance); + + if ((instanceOrOptions as FastifyAdapterBaseOptions)?.skipMiddie) { + this.isMiddieRegistered = true; + } } public async init() {