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

+8 -7
View File
@@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Mar 24, 2026 at 10:33 PM
-- Generation Time: Mar 29, 2026 at 12:54 AM
-- Server version: 10.11.14-MariaDB-0ubuntu0.24.04.1
-- PHP Version: 8.3.30
@@ -24,14 +24,15 @@ SET time_zone = "+00:00";
-- --------------------------------------------------------
--
-- Table structure for table `cdnfiles`
-- Table structure for table `files`
--
CREATE TABLE `cdnfiles` (
CREATE TABLE `files` (
`id` bigint(20) NOT NULL,
`path` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`hash` char(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`size` bigint(20) NOT NULL,
`host` int(1) NOT NULL DEFAULT 0,
`mimeType` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
@@ -185,9 +186,9 @@ CREATE TABLE `verifycodes` (
--
--
-- Indexes for table `cdnfiles`
-- Indexes for table `files`
--
ALTER TABLE `cdnfiles`
ALTER TABLE `files`
ADD PRIMARY KEY (`id`);
--
@@ -251,9 +252,9 @@ ALTER TABLE `verifycodes`
--
--
-- AUTO_INCREMENT for table `cdnfiles`
-- AUTO_INCREMENT for table `files`
--
ALTER TABLE `cdnfiles`
ALTER TABLE `files`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
--
+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
}
})