Add support for github host
This commit is contained in:
3 files changed
+18
-13
No files matched your search
@@ -3,7 +3,7 @@
|
|||||||
-- https://www.phpmyadmin.net/
|
-- https://www.phpmyadmin.net/
|
||||||
--
|
--
|
||||||
-- Host: localhost
|
-- 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
|
-- Server version: 10.11.14-MariaDB-0ubuntu0.24.04.1
|
||||||
-- PHP Version: 8.3.30
|
-- 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,
|
`id` bigint(20) NOT NULL,
|
||||||
`path` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
`path` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||||
`hash` char(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
`hash` char(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||||
`size` bigint(20) 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
|
`mimeType` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
) 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`);
|
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;
|
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
+2
-1
@@ -95,11 +95,12 @@ export const resetCodes = mysqlTable('resetcodes', {
|
|||||||
type: int('type').notNull()
|
type: int('type').notNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
export const cdnFiles = mysqlTable('cdnfiles', {
|
export const files = mysqlTable('files', {
|
||||||
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
||||||
path: varchar('path', { length: 4096 }).notNull(),
|
path: varchar('path', { length: 4096 }).notNull(),
|
||||||
hash: char('hash', { length: 128 }).notNull(),
|
hash: char('hash', { length: 128 }).notNull(),
|
||||||
size: bigint('size', { mode: 'number' }).notNull(),
|
size: bigint('size', { mode: 'number' }).notNull(),
|
||||||
|
host: int('size').notNull().default(0),
|
||||||
mimeType: varchar('mimeType', { length: 255 })
|
mimeType: varchar('mimeType', { length: 255 })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Context } from 'elysia'
|
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 { getDatabaseConnection, jsonResponse } from '../../../lib/util'
|
||||||
import { eq, sql } from 'drizzle-orm'
|
import { eq, sql } from 'drizzle-orm'
|
||||||
|
|
||||||
@@ -13,9 +13,9 @@ export const handler = async (context: Context) => {
|
|||||||
const downloadId = Number(context.query.downloadId)
|
const downloadId = Number(context.query.downloadId)
|
||||||
|
|
||||||
const result = await db
|
const result = await db
|
||||||
.select({ path: cdnFiles.path, hash: cdnFiles.hash })
|
.select({ path: files.path, hash: files.hash, host: files.host })
|
||||||
.from(cdnFiles)
|
.from(files)
|
||||||
.where(eq(cdnFiles.id, downloadId))
|
.where(eq(files.id, downloadId))
|
||||||
.execute()
|
.execute()
|
||||||
|
|
||||||
if (result.length != 1)
|
if (result.length != 1)
|
||||||
@@ -38,7 +38,10 @@ export const handler = async (context: Context) => {
|
|||||||
return jsonResponse({
|
return jsonResponse({
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
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
|
hash: result[0].hash
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user