Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Apply Ajv TS workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
fardjad committed Sep 26, 2023
1 parent c8c6dd3 commit 332945f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/fastify-server-factory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Cradle } from "./container.ts";
import type { OperationHandler } from "./operation-handler.ts";
import fastifyStatic from "@fastify/static";
import Ajv from "ajv";
import ajvModule from "ajv";
import fastify from "fastify";
import openapiGlue from "fastify-openapi-glue";
import { glob } from "glob";
Expand All @@ -11,6 +11,10 @@ import { fileURLToPath } from "node:url";
import swaggerUiDist from "swagger-ui-dist";
import traverse from "traverse";

// https://github.com/ajv-validator/ajv/issues/2132
// eslint-disable-next-line @typescript-eslint/naming-convention
const Ajv = ajvModule.default;

// FIXME: fix the types
const createOpenapiGlueService = async ({ container }: Partial<Cradle>) => {
const routeHandlerFiles = await glob("**/*.handler.[tj]s", {
Expand Down Expand Up @@ -53,7 +57,9 @@ const configureOpenapiGlue = async ({
throw new Error("Missing httpPart");
}

const compiler = schemaCompilers[request.httpPart] as Ajv | undefined;
const compiler = schemaCompilers[request.httpPart] as
| ajvModule.default
| undefined;
if (!compiler) {
throw new Error(`Missing compiler for ${request.httpPart}`);
}
Expand Down

0 comments on commit 332945f

Please sign in to comment.