umami/lib/query.ts
2023-04-01 15:44:30 -07:00

20 lines
416 B
TypeScript

import cache from 'lib/cache';
import { getWebsite } from 'queries';
import { Website } from './types';
export async function loadWebsite(websiteId: string): Promise<Website> {
let website;
if (cache.enabled) {
website = await cache.fetchWebsite(websiteId);
} else {
website = await getWebsite({ id: websiteId });
}
if (!website || website.deletedAt) {
return null;
}
return website;
}