Finish reworking launcher manifest stuff

This commit is contained in:
Lncvrt committed 2026-02-26 22:47:15 -07:00
1 parent 02bad685da
commit fcdee21ab5
10 files changed
+251 -229

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import { Context } from 'elysia'
import { cdnFiles, launcherVersionManifest } from '../../../lib/tables'
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
import { eq, sql } from 'drizzle-orm'
export const handler = async (context: Context) => {
const dbResult = getDatabaseConnection(0)
if (!dbResult) return jsonResponse({ success: false, data: null }, 400)
const { connection, db } = dbResult
const gameId = context.query.gameId
const downloadId = Number(context.query.downloadId)
const result = await db
.select({ path: cdnFiles.path, hash: cdnFiles.hash })
.from(cdnFiles)
.where(eq(cdnFiles.id, downloadId))
.execute()
if (result.length != 1)
return jsonResponse({ success: false, data: null }, 400)
if (gameId)
await db
.update(launcherVersionManifest)
.set({
downloads: sql`${launcherVersionManifest.downloads} + 1`
})
.where(eq(launcherVersionManifest.id, gameId))
connection.end()
return jsonResponse({
success: true,
data: {
url: 'https://games-r2.lncvrt.xyz/' + result[0].path,
hash: result[0].hash
}
})
}