Add an endpoint for getting the latest berry dash version number

This commit is contained in:
Lncvrt committed 2026-01-21 21:56:24 -07:00
1 parent 2da0f3501f
commit c179b99806
2 files changed
+38

No files matched your search

@@ -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'
}