Add TTL cache for game version/loader APIs and enrich upload metadata

This commit is contained in:
CPTProgrammer
2026-07-10 06:54:14 +08:00
parent 7ddbd36c63
commit e8d4994cec
5 changed files with 73 additions and 33 deletions
+14 -1
View File
@@ -1,5 +1,5 @@
import { curseforgeClient } from "@/services/clients";
import { uploadFile } from "@/lib/curseforge";
import { uploadFile, getGameVersions } from "@/lib/curseforge";
import { resolveVersionName, buildJarPath } from "@/lib/utils/format";
import { readJarBlob } from "@/lib/utils/file";
import type { UploadMetadata } from "@/types";
@@ -26,11 +26,24 @@ export async function publishCurseForgeVersion(
const primaryBlob = readJarBlob(primaryPath);
const gameVersions = await getGameVersions(curseforgeClient);
const resolveId = (name: string): number => {
const found = gameVersions.find((v) => v.name === name);
if (!found) throw new Error(`Game version "${name}" not found in CurseForge`);
return found.id;
};
const metadata: UploadMetadata = {
changelog: input.changelog,
changelogType: "markdown",
displayName,
releaseType: input.versionType,
gameVersions: [
resolveId(mcVersion),
...config.curseforge.loaders.map(resolveId),
...config.curseforge.environment.map(resolveId),
],
relations: config.curseforge.relations,
};
+1
View File
@@ -47,6 +47,7 @@ export async function publishModrinthVersion(
project_id: config.modrinth.project_id,
name: versionName,
version_number: versionNumber,
changelog: input.changelog,
game_versions: [mcVersion],
version_type: input.versionType,
loaders: config.modrinth.loaders,