Fix connection
This commit is contained in:
@@ -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
|
||||
|
||||
const env =
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { launcherUpdates } from '../../lib/tables'
|
||||
import { desc, eq } from 'drizzle-orm'
|
||||
import { getDatabaseConnection } from '../../lib/util'
|
||||
import { getDatabaseConnection, jsonResponse } from '../../lib/util'
|
||||
|
||||
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
|
||||
.select({
|
||||
|
||||
@@ -4,7 +4,10 @@ import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
|
||||
import { Context } from 'elysia'
|
||||
|
||||
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 arch = context.query.arch as string | undefined
|
||||
|
||||
@@ -4,7 +4,10 @@ import { getDatabaseConnection, jsonResponse } from '../../lib/util'
|
||||
import { Context } from 'elysia'
|
||||
|
||||
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 arch = context.query.arch as string | undefined
|
||||
|
||||
Reference in New Issue
Block a user