diff --git a/server/api/reverseSearch.ts b/server/api/reverseSearch.ts deleted file mode 100644 index da41aa8..0000000 --- a/server/api/reverseSearch.ts +++ /dev/null @@ -1,12 +0,0 @@ -export default defineEventHandler(async (event): Promise => { - const query = getQuery(event); - - const projectIds = await DB.getForProject(query.id as string); - - if (projectIds instanceof Error) { - setResponseStatus(event, 500); - return []; - } - - return projectIds; -}); diff --git a/server/utils/db/sql.ts b/server/utils/db/sql.ts index 54dbda5..98cfeee 100644 --- a/server/utils/db/sql.ts +++ b/server/utils/db/sql.ts @@ -54,7 +54,7 @@ export const DB = { ); } - return result.rows[0].count as number; + return result.rows[0]!.count as number; } catch (error) { return new Error(`Failed to add connections: ${error}`); } diff --git a/server/utils/processing/connections/fetching.ts b/server/utils/processing/connections/fetching.ts index e8fe6d9..92ed479 100644 --- a/server/utils/processing/connections/fetching.ts +++ b/server/utils/processing/connections/fetching.ts @@ -1,4 +1,4 @@ -import { ExtendedProjectData, ProjectData } from "./types"; +import type { ExtendedProjectData } from "./types"; export async function getModpackIds( offset: number, @@ -25,14 +25,16 @@ export async function getProjectData( }, }); - return data.map((value) => ({ - id: value.id, - name: value.title, - latest_version: value.versions[value.versions.length - 1], - description: value.description, - icon_url: value.icon_url, - downloads: value.downloads, - })); + return data + .filter((value) => value.versions.length > 0) + .map((value) => ({ + id: value.id, + name: value.title, + latest_version: value.versions[value.versions.length - 1]!, + description: value.description, + icon_url: value.icon_url, + downloads: value.downloads, + })); } export async function getVersionDependencies( diff --git a/server/utils/processing/connections/processing.ts b/server/utils/processing/connections/processing.ts index 2483c58..4c57677 100644 --- a/server/utils/processing/connections/processing.ts +++ b/server/utils/processing/connections/processing.ts @@ -1,11 +1,11 @@ import { LOGGER } from "~~/server/tasks/analyze"; import { DB } from "../../db/sql"; import { - getProjectData, getModpackIds, + getProjectData, getVersionDependencies, } from "./fetching"; -import { ExtendedProjectData, ProjectData } from "./types"; +import type { ExtendedProjectData } from "./types"; export async function updateConnections() { LOGGER.info("updating connections [starting]");