Initial commit
This commit is contained in:
27
src/routes/launcher/loader/update-data.ts
Normal file
27
src/routes/launcher/loader/update-data.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { Context } from "elysia";
|
||||
import { MySql2Database } from "drizzle-orm/mysql2";
|
||||
import { launcherUpdates } from "../../../lib/tables";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { jsonResponse } from "../../../lib/util";
|
||||
|
||||
export async function handler(context: Context, db: MySql2Database) {
|
||||
const versionsRaw = await db.select({
|
||||
id: launcherUpdates.id,
|
||||
releaseDate: launcherUpdates.releaseDate,
|
||||
downloadUrls: launcherUpdates.downloadUrls,
|
||||
platforms: launcherUpdates.platforms
|
||||
})
|
||||
.from(launcherUpdates)
|
||||
.where(eq(launcherUpdates.hidden, false))
|
||||
.orderBy(launcherUpdates.place)
|
||||
.limit(1)
|
||||
.execute()
|
||||
|
||||
const versions = versionsRaw.map(v => ({
|
||||
...v,
|
||||
downloadUrls: JSON.parse(v.downloadUrls),
|
||||
platforms: JSON.parse(v.platforms)
|
||||
}))
|
||||
|
||||
return jsonResponse(versions[0])
|
||||
}
|
||||
Reference in New Issue
Block a user