Add an endpoint for getting the latest berry dash version number

This commit is contained in:
2026-01-21 21:56:24 -07:00
parent 2da0f3501f
commit c179b99806
2 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { games, launcherVersionManifest } from '../../../lib/tables'
import { and, asc, desc, eq } from 'drizzle-orm'
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
import { Context } from 'elysia'
export async function handler (context: Context) {
const dbResult = getDatabaseConnection(0)
if (!dbResult)
return jsonResponse({ error: 'Failed to connect to database' }, 500)
const { connection, db } = dbResult
const version = await db
.select({
versionName: launcherVersionManifest.versionName
})
.from(launcherVersionManifest)
.where(
and(
eq(launcherVersionManifest.hidden, false),
eq(launcherVersionManifest.game, 1)
)
)
.orderBy(desc(launcherVersionManifest.place))
.limit(1)
.execute()
connection.end()
return version[0] ? version[0].versionName : '-1'
}