hello worlds

This commit is contained in:
Holden
2026-06-26 18:11:52 -05:00
commit e208f1ad5a
61 changed files with 15566 additions and 0 deletions

53
src/lib/api.ts Normal file
View File

@@ -0,0 +1,53 @@
import { TWY_API_URL } from 'astro:env/server';
import type { LatestBuildsResponse, PatchNote } from './types/api/builds';
import { ApiResult } from './types/api';
const BUILDS_V1 = "api/builds/v1";
export const api = {
builds: {
v1: {
async getLatestVersions(): Promise<ApiResult<LatestBuildsResponse>> {
const response = await fetch(`${TWY_API_URL}/${BUILDS_V1}/latest`, {
headers: {
"Content-Type": "application/json",
},
cache: "no-store",
});
if (!response.ok) {
console.error("Failed to load latest versions.", {
status: response.status,
statusText: response.statusText,
});
return ApiResult.failure<LatestBuildsResponse>("Failed to load latest versions.");
}
var obj = (await response.json()) as LatestBuildsResponse;
return ApiResult.success(obj);
},
async getPatchNotes(): Promise<ApiResult<PatchNote[]>> {
const response = await fetch(`${TWY_API_URL}/${BUILDS_V1}/patchNotes`, {
headers: {
"Content-Type": "application/json",
},
cache: "no-store",
});
if (!response.ok) {
console.error("Failed to load account.", {
status: response.status,
statusText: response.statusText,
});
return ApiResult.failure<PatchNote[]>("Failed to load latest versions.");
}
var obj = (await response.json()) as PatchNote[];
return ApiResult.success(obj);
}
}
}
}