Add support for github host

This commit is contained in:
Lncvrt committed 2026-03-28 17:57:11 -07:00
1 parent 1b78f36a8a
commit d7da88fc90
3 files changed
+18 -13

No files matched your search

+2 -1
View File
@@ -95,11 +95,12 @@ export const resetCodes = mysqlTable('resetcodes', {
type: int('type').notNull()
})
export const cdnFiles = mysqlTable('cdnfiles', {
export const files = mysqlTable('files', {
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
path: varchar('path', { length: 4096 }).notNull(),
hash: char('hash', { length: 128 }).notNull(),
size: bigint('size', { mode: 'number' }).notNull(),
host: int('size').notNull().default(0),
mimeType: varchar('mimeType', { length: 255 })
})
+8 -5
View File
@@ -1,5 +1,5 @@
import { Context } from 'elysia'
import { cdnFiles, launcherVersionManifest, mods } from '../../../lib/tables'
import { files, launcherVersionManifest, mods } from '../../../lib/tables'
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
import { eq, sql } from 'drizzle-orm'
@@ -13,9 +13,9 @@ export const handler = async (context: Context) => {
const downloadId = Number(context.query.downloadId)
const result = await db
.select({ path: cdnFiles.path, hash: cdnFiles.hash })
.from(cdnFiles)
.where(eq(cdnFiles.id, downloadId))
.select({ path: files.path, hash: files.hash, host: files.host })
.from(files)
.where(eq(files.id, downloadId))
.execute()
if (result.length != 1)
@@ -38,7 +38,10 @@ export const handler = async (context: Context) => {
return jsonResponse({
success: true,
data: {
url: 'https://games-r2.lncvrt.xyz/' + result[0].path,
url:
result[0].host == 1
? `https://github.com/${result[0].path[0]}/${result[0].path[1]}/releases/download/${result[0].path[2]}/${result[0].path[3]}`
: 'https://games-r2.lncvrt.xyz/' + result[0].path,
hash: result[0].hash
}
})