add version check for 20230414 client

This commit is contained in:
Devin Zuczek
2026-07-23 12:23:30 -04:00
parent 7ab171b646
commit 2f6a40279d
10 changed files with 42 additions and 23 deletions
+2 -2
View File
@@ -135,9 +135,9 @@ export const ApiConfigV2 = JsonObject.describe(
'The static client config, plus a ShareBaseUrl templated from the deploy domain'
)
/** `GET /api/versioncheck/v4` — always the "you are up to date" answer. */
/** `GET /api/versioncheck/v4` — whether the client's `?v=` build matches GAME_VERSION. */
export const VersionCheck = z.object({
VersionStatus: z.int().describe('0 = current'),
VersionStatus: z.int().describe('0 = current, 1 = client on a different build'),
UpdateNotificationStage: z.int(),
IsVersionIslanded: z.boolean(),
IsCrossPlayDisabled: z.boolean(),
+7 -4
View File
@@ -1,6 +1,8 @@
import { Hono } from 'hono'
import { describeRoute } from 'hono-openapi'
import { GAME_VERSION } from '@repo/domain'
import apiConfigV2 from '../../static/api-config-v2.json'
import gameConfigsV1All from '../../static/gameconfigs-v1-all.json'
import {
@@ -97,13 +99,14 @@ export const configRoutes = new Hono<App>({ strict: false })
tags: ['Config'],
summary: 'Client version check',
description:
'Whether the client build is current. Always the “up to date, nothing islanded” ' +
'answer — this server does not gate on client version.',
responses: { 200: json(VersionCheck, 'Always current') },
'Whether the client build is current. Compares the clients `?v=` build against ' +
'our target `GAME_VERSION`: `VersionStatus` is 0 when they match, 1 when the ' +
'client is on a different build.',
responses: { 200: json(VersionCheck, 'Version status') },
}),
(c) =>
c.json({
VersionStatus: 0,
VersionStatus: c.req.query('v') === GAME_VERSION ? 0 : 1,
UpdateNotificationStage: 0,
IsVersionIslanded: false,
IsCrossPlayDisabled: false,
+9 -2
View File
@@ -2,6 +2,8 @@ import { adminSecretsStore, env } from 'cloudflare:test'
import { exports } from 'cloudflare:workers'
import { beforeAll, describe, expect, test } from 'vitest'
import { GAME_VERSION } from '@repo/domain'
import '../../api.app'
import { createImage, getImageByName, SCHEMA_DDL as IMAGES_SCHEMA_DDL } from '../../images-db'
@@ -135,11 +137,16 @@ describe('public endpoints', () => {
expect(body).toMatchObject({ ReportBudget: 125, VersionRegex: '.*' })
})
test('GET /api/versioncheck/v4', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/versioncheck/v4`)
test('GET /api/versioncheck/v4 reports current for the matching build', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/versioncheck/v4?v=${GAME_VERSION}`)
expect(await res.json()).toMatchObject({ VersionStatus: 0 })
})
test('GET /api/versioncheck/v4 flags a mismatched build', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/versioncheck/v4?v=19990101`)
expect(await res.json()).toMatchObject({ VersionStatus: 1 })
})
test('GET /api/relationships/v2/get returns empty array for a player with none', async () => {
const res = await exports.default.fetch(`${ORIGIN}/api/relationships/v2/get`, {
headers: await bearer('99999'),