Make the launcher latest endpoint use the db

This commit is contained in:
2025-11-01 21:30:25 -07:00
parent 982b412eeb
commit 4040d5abdd
2 changed files with 16 additions and 3 deletions

View File

@@ -29,7 +29,7 @@ const app = new Elysia()
}))
app.get("/launcher/versions", () => launcherVersionsHandler(db))
app.get("/launcher/latest", launcherLatestHandler)
app.get("/launcher/latest", () => launcherLatestHandler(db))
app.get("/launcher/loader/latest", launcherLoaderLatestHandler)
app.get("/launcher/loader/update-data", () => launcherLoaderUpdateDataHandler(db))
app.all("*", () => jsonResponse({ message: "No endpoint found (are you using the correct request method?)" }, 404))

View File

@@ -1,3 +1,16 @@
export async function handler() {
return "1.1.0"
import { MySql2Database } from "drizzle-orm/mysql2"
import { launcherUpdates } from "../../lib/tables"
import { eq } from "drizzle-orm"
export async function handler(db: MySql2Database) {
const version = await db.select({
id: launcherUpdates.id
})
.from(launcherUpdates)
.where(eq(launcherUpdates.hidden, false))
.orderBy(launcherUpdates.place)
.limit(1)
.execute()
return version[0].id
}