fosrl.pangolin/server/lib/hostMeta.ts

29 lines
669 B
TypeScript
Raw Permalink Normal View History

2025-08-14 17:06:07 -07:00
import { db, HostMeta } from "@server/db";
2025-06-04 12:02:07 -04:00
import { hostMeta } from "@server/db";
2025-04-27 13:03:00 -04:00
import { v4 as uuidv4 } from "uuid";
2025-08-14 17:06:07 -07:00
let gotHostMeta: HostMeta | undefined;
2025-04-27 13:03:00 -04:00
export async function setHostMeta() {
const [existing] = await db.select().from(hostMeta).limit(1);
if (existing && existing.hostMetaId) {
return;
}
const id = uuidv4();
await db
.insert(hostMeta)
.values({ hostMetaId: id, createdAt: new Date().getTime() });
}
2025-08-14 17:06:07 -07:00
export async function getHostMeta() {
if (gotHostMeta) {
return gotHostMeta;
}
const [meta] = await db.select().from(hostMeta).limit(1);
gotHostMeta = meta;
return meta;
}