Skip to content

Commit

Permalink
chore(fastify): explicitly cast plugin imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jul 7, 2022
1 parent 4db51ac commit 3a9aa75
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/platform-fastify/adapters/fastify-adapter.ts
Expand Up @@ -444,14 +444,19 @@ export class FastifyAdapter<
}

public enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>) {
this.register(import('@fastify/cors'), options);
this.register(
import('@fastify/cors') as Parameters<TInstance['register']>[0],
options,
);
}

public registerParserMiddleware(prefix?: string, rawBody?: boolean) {
if (this._isParserRegistered) {
return;
}
this.register(import('@fastify/formbody'));
this.register(
import('@fastify/formbody') as Parameters<TInstance['register']>[0],
);

if (rawBody) {
this.registerContentParserWithRawBody();
Expand Down Expand Up @@ -530,7 +535,9 @@ export class FastifyAdapter<

private async registerMiddie() {
this.isMiddieRegistered = true;
await this.register(import('@fastify/middie'));
await this.register(
import('@fastify/middie') as Parameters<TInstance['register']>[0],
);
}

private getRequestOriginalUrl(rawRequest: TRawRequest) {
Expand Down

0 comments on commit 3a9aa75

Please sign in to comment.