Skip to content

Commit

Permalink
Merge pull request #13734 from ancyrweb/master
Browse files Browse the repository at this point in the history
feat(fastify-adapter): support for skipping middie registration
  • Loading branch information
kamilmysliwiec authored Jul 1, 2024
2 parents 783e833 + c7d2978 commit 68d91ac
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/platform-fastify/adapters/fastify-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,33 @@ import {
FastifyViewOptions,
} from '../interfaces/external';

type FastifyAdapterBaseOptions<
Server extends RawServerBase = RawServerDefault,
Logger extends FastifyBaseLogger = FastifyBaseLogger,
> = FastifyServerOptions<Server, Logger> & {
skipMiddie?: boolean;
};

type FastifyHttp2SecureOptions<
Server extends http2.Http2SecureServer,
Logger extends FastifyBaseLogger = FastifyBaseLogger,
> = FastifyServerOptions<Server, Logger> & {
> = FastifyAdapterBaseOptions<Server, Logger> & {
http2: true;
https: http2.SecureServerOptions;
};

type FastifyHttp2Options<
Server extends http2.Http2Server,
Logger extends FastifyBaseLogger = FastifyBaseLogger,
> = FastifyServerOptions<Server, Logger> & {
> = FastifyAdapterBaseOptions<Server, Logger> & {
http2: true;
http2SessionTimeout?: number;
};

type FastifyHttpsOptions<
Server extends https.Server,
Logger extends FastifyBaseLogger = FastifyBaseLogger,
> = FastifyServerOptions<Server, Logger> & {
> = FastifyAdapterBaseOptions<Server, Logger> & {
https: https.ServerOptions;
};

Expand Down Expand Up @@ -210,7 +217,7 @@ export class FastifyAdapter<
| FastifyHttp2Options<any>
| FastifyHttp2SecureOptions<any>
| FastifyHttpsOptions<any>
| FastifyServerOptions<TServer>,
| FastifyAdapterBaseOptions<TServer>,
) {
super();

Expand All @@ -223,7 +230,12 @@ export class FastifyAdapter<
},
...(instanceOrOptions as FastifyServerOptions),
});

this.setInstance(instance);

if ((instanceOrOptions as FastifyAdapterBaseOptions)?.skipMiddie) {
this.isMiddieRegistered = true;
}
}

public async init() {
Expand Down

0 comments on commit 68d91ac

Please sign in to comment.