Switch to headers for mods manifest & version manifest

This commit is contained in:
Lncvrt committed 2026-10-02 10:43:27 -07:00
1 parent de189bb7b7
commit ffe3d99a9f
3 files changed
+18 -35

No files matched your search

+4 -13
View File
@@ -963,8 +963,6 @@ app.get('/launcher/mods', context => launcherModsGetHandler(context), {
tags: ['Launcher'] tags: ['Launcher']
}, },
query: t.Object({ query: t.Object({
platform: t.String({ examples: ['windows', 'macos', 'linux'] }),
arch: t.String({ examples: ['x86', 'x64', 'arm64'] }),
version: t.String() version: t.String()
}), }),
headers: t.Object({ headers: t.Object({
@@ -972,7 +970,8 @@ app.get('/launcher/mods', context => launcherModsGetHandler(context), {
t.String({ t.String({
hide: true hide: true
}) })
) ),
clientplatform: t.String()
}) })
}) })
app.get('/launcher/versions', context => launcherVersionsHandler(context), { app.get('/launcher/versions', context => launcherVersionsHandler(context), {
@@ -981,21 +980,13 @@ app.get('/launcher/versions', context => launcherVersionsHandler(context), {
'The endpoint for getting the launcher manifest.\n\nNote: if going to use the params, both must be provided at the same time.', 'The endpoint for getting the launcher manifest.\n\nNote: if going to use the params, both must be provided at the same time.',
tags: ['Launcher'] tags: ['Launcher']
}, },
query: t.Object({
platform: t.Optional(t.String({ examples: ['windows', 'macos', 'linux'] })),
arch: t.Optional(t.String({ examples: ['x86', 'x64', 'arm64'] })),
game: t.Optional(
t.String({
description: "Adding this will make it only show a Game ID's versions"
})
)
}),
headers: t.Object({ headers: t.Object({
'x-forwarded-for': t.Optional( 'x-forwarded-for': t.Optional(
t.String({ t.String({
hide: true hide: true
}) })
) ),
clientplatform: t.Optional(t.String())
}) })
}) })
app.get('/launcher/latest', launcherLatestHandler, { app.get('/launcher/latest', launcherLatestHandler, {
+3 -2
View File
@@ -9,8 +9,9 @@ export const handler = async (context: Context) => {
return jsonResponse({ error: 'Failed to connect to database' }, 500) return jsonResponse({ error: 'Failed to connect to database' }, 500)
const { connection, db } = dbResult const { connection, db } = dbResult
const platform = context.query.platform const clientplatform = context.headers.clientplatform
const arch = context.query.arch const platform = clientplatform?.split('-')[0]
const arch = clientplatform?.split('-')[1]
const version = context.query.version const version = context.query.version
let platformsToShow: string[] | null = null let platformsToShow: string[] | null = null
+11 -20
View File
@@ -9,9 +9,9 @@ export const handler = async (context: Context) => {
return jsonResponse({ error: 'Failed to connect to database' }, 500) return jsonResponse({ error: 'Failed to connect to database' }, 500)
const { connection, db } = dbResult const { connection, db } = dbResult
const platform = context.query.platform const clientplatform = context.headers.clientplatform
const arch = context.query.arch const platform = clientplatform?.split('-')[0]
const game = context.query.game const arch = clientplatform?.split('-')[1]
let showAll = false let showAll = false
if (!platform || !arch) showAll = true if (!platform || !arch) showAll = true
@@ -100,14 +100,7 @@ export const handler = async (context: Context) => {
lastRevision: launcherVersionManifest.lastRevision lastRevision: launcherVersionManifest.lastRevision
}) })
.from(launcherVersionManifest) .from(launcherVersionManifest)
.where( .where(eq(launcherVersionManifest.hidden, false))
game != null
? and(
eq(launcherVersionManifest.game, Number(game)),
eq(launcherVersionManifest.hidden, false)
)
: eq(launcherVersionManifest.hidden, false)
)
.orderBy( .orderBy(
asc(launcherVersionManifest.game), asc(launcherVersionManifest.game),
desc(launcherVersionManifest.place) desc(launcherVersionManifest.place)
@@ -167,15 +160,13 @@ export const handler = async (context: Context) => {
return v.download !== undefined return v.download !== undefined
}) })
if (!game) { const gamesListRaw = await db.select().from(games).execute()
const gamesListRaw = await db.select().from(games).execute() const gamesList = gamesListRaw.map(v => ({
const gamesList = gamesListRaw.map(v => ({ ...v,
...v, categoryNames: JSON.parse(v.categoryNames)
categoryNames: JSON.parse(v.categoryNames) }))
}))
connection.end() connection.end()
return jsonResponse({ versions: versions, games: gamesList }) return jsonResponse({ versions: versions, games: gamesList })
} else return jsonResponse(versions)
} }