Skip to content

Commit

Permalink
fix(platform-fastify): remove unused generics
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed May 18, 2021
1 parent 8b866b9 commit df4aba6
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions packages/platform-fastify/adapters/fastify-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@ import {

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

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

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

export class FastifyAdapter<
TServer extends RawServerBase = RawServerDefault,
TRawRequest extends RawRequestDefaultExpression<TServer> = RawRequestDefaultExpression<TServer>,
TRawResponse extends RawReplyDefaultExpression<TServer> = RawReplyDefaultExpression<TServer>
TRawResponse extends RawReplyDefaultExpression<TServer> = RawReplyDefaultExpression<TServer>,
> extends AbstractHttpAdapter<
TServer,
FastifyRequest<RequestGenericInterface, TServer, TRawRequest>,
Expand All @@ -84,7 +84,7 @@ export class FastifyAdapter<
constructor(
instanceOrOptions:
| FastifyInstance<TServer>
| FastifyHttp2Options<TServer>
| FastifyHttp2Options<any>
| FastifyHttp2SecureOptions<any>
| FastifyHttpsOptions<any>
| FastifyServerOptions<TServer> = fastify() as any,
Expand Down Expand Up @@ -171,22 +171,18 @@ export class FastifyAdapter<
return this.instance.setErrorHandler(handler);
}

public setNotFoundHandler(
handler: Parameters<
FastifyInstance<TServer, TRawRequest, TRawResponse>['setNotFoundHandler']
>[0],
) {
return this.instance.setNotFoundHandler(handler);
public setNotFoundHandler(handler: Function) {
return this.instance.setNotFoundHandler(handler as any);
}

public getHttpServer<T = TServer>(): T {
return (this.instance.server as unknown) as T;
return this.instance.server as unknown as T;
}

public getInstance<
T = FastifyInstance<TServer, TRawRequest, TRawResponse>
T = FastifyInstance<TServer, TRawRequest, TRawResponse>,
>(): T {
return (this.instance as unknown) as T;
return this.instance as unknown as T;
}

public register<Options extends FastifyPluginOptions = any>(
Expand Down Expand Up @@ -295,8 +291,9 @@ export class FastifyAdapter<
// The following type assertion is valid as we enforce "middie" plugin registration
// which enhances the FastifyInstance with the "use()" method.
// ref https://github.com/fastify/middie/pull/55
const instanceWithUseFn = (this
.instance as unknown) as FastifyInstance & { use: Function };
const instanceWithUseFn = this.instance as unknown as FastifyInstance & {
use: Function;
};

instanceWithUseFn.use(
normalizedPath,
Expand Down

0 comments on commit df4aba6

Please sign in to comment.