Files
CodeNomad/packages/ui/src/lib/server-meta.ts
2025-11-21 00:04:01 +00:00

21 lines
504 B
TypeScript

import type { ServerMeta } from "../../../server/src/api-types"
import { serverApi } from "./api-client"
let cachedMeta: ServerMeta | null = null
let pendingMeta: Promise<ServerMeta> | null = null
export async function getServerMeta(): Promise<ServerMeta> {
if (cachedMeta) {
return cachedMeta
}
if (pendingMeta) {
return pendingMeta
}
pendingMeta = serverApi.fetchServerMeta().then((meta) => {
cachedMeta = meta
pendingMeta = null
return meta
})
return pendingMeta
}