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']
},
query: t.Object({
platform: t.String({ examples: ['windows', 'macos', 'linux'] }),
arch: t.String({ examples: ['x86', 'x64', 'arm64'] }),
version: t.String()
}),
headers: t.Object({
@@ -972,7 +970,8 @@ app.get('/launcher/mods', context => launcherModsGetHandler(context), {
t.String({
hide: true
})
)
),
clientplatform: t.String()
})
})
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.',
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({
'x-forwarded-for': t.Optional(
t.String({
hide: true
})
)
),
clientplatform: t.Optional(t.String())
})
})
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)
const { connection, db } = dbResult
const platform = context.query.platform
const arch = context.query.arch
const clientplatform = context.headers.clientplatform
const platform = clientplatform?.split('-')[0]
const arch = clientplatform?.split('-')[1]
const version = context.query.version
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)
const { connection, db } = dbResult
const platform = context.query.platform
const arch = context.query.arch
const game = context.query.game
const clientplatform = context.headers.clientplatform
const platform = clientplatform?.split('-')[0]
const arch = clientplatform?.split('-')[1]
let showAll = false
if (!platform || !arch) showAll = true
@@ -100,14 +100,7 @@ export const handler = async (context: Context) => {
lastRevision: launcherVersionManifest.lastRevision
})
.from(launcherVersionManifest)
.where(
game != null
? and(
eq(launcherVersionManifest.game, Number(game)),
eq(launcherVersionManifest.hidden, false)
)
: eq(launcherVersionManifest.hidden, false)
)
.where(eq(launcherVersionManifest.hidden, false))
.orderBy(
asc(launcherVersionManifest.game),
desc(launcherVersionManifest.place)
@@ -167,15 +160,13 @@ export const handler = async (context: Context) => {
return v.download !== undefined
})
if (!game) {
const gamesListRaw = await db.select().from(games).execute()
const gamesList = gamesListRaw.map(v => ({
...v,
categoryNames: JSON.parse(v.categoryNames)
}))
const gamesListRaw = await db.select().from(games).execute()
const gamesList = gamesListRaw.map(v => ({
...v,
categoryNames: JSON.parse(v.categoryNames)
}))
connection.end()
connection.end()
return jsonResponse({ versions: versions, games: gamesList })
} else return jsonResponse(versions)
return jsonResponse({ versions: versions, games: gamesList })
}