Fix connection

This commit is contained in:
2025-11-17 15:55:31 -07:00
parent fe82889b0a
commit e0611f66c9
4 changed files with 14 additions and 5 deletions

View File

@@ -14,7 +14,7 @@ export function jsonResponse (data: any, status = 200) {
}) })
} }
export function getDatabaseConnection (type: number = 0) { export function getDatabaseConnection (type: number) {
if (type !== 0 && type !== 1) return null if (type !== 0 && type !== 1) return null
const env = const env =

View File

@@ -1,9 +1,12 @@
import { launcherUpdates } from '../../lib/tables' import { launcherUpdates } from '../../lib/tables'
import { desc, eq } from 'drizzle-orm' import { desc, eq } from 'drizzle-orm'
import { getDatabaseConnection } from '../../lib/util' import { getDatabaseConnection, jsonResponse } from '../../lib/util'
export async function handler () { export async function handler () {
const { connection, db } = getDatabaseConnection() const dbResult = getDatabaseConnection(0)
if (!dbResult)
return jsonResponse({ error: 'Failed to connect to database' }, 500)
const { connection, db } = dbResult
const version = await db const version = await db
.select({ .select({

View File

@@ -4,7 +4,10 @@ import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
import { Context } from 'elysia' import { Context } from 'elysia'
export async function handler (context: Context) { export async function handler (context: Context) {
const { connection, db } = getDatabaseConnection() const dbResult = getDatabaseConnection(0)
if (!dbResult)
return jsonResponse({ error: 'Failed to connect to database' }, 500)
const { connection, db } = dbResult
const platform = context.query.platform as string | undefined const platform = context.query.platform as string | undefined
const arch = context.query.arch as string | undefined const arch = context.query.arch as string | undefined

View File

@@ -4,7 +4,10 @@ import { getDatabaseConnection, jsonResponse } from '../../lib/util'
import { Context } from 'elysia' import { Context } from 'elysia'
export async function handler (context: Context) { export async function handler (context: Context) {
const { connection, db } = getDatabaseConnection() const dbResult = getDatabaseConnection(0)
if (!dbResult)
return jsonResponse({ error: 'Failed to connect to database' }, 500)
const { connection, db } = dbResult
const platform = context.query.platform as string | undefined const platform = context.query.platform as string | undefined
const arch = context.query.arch as string | undefined const arch = context.query.arch as string | undefined