Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 647 Bytes
ac64cdc 73e0644 ac64cdc 73e0644 ac64cdc 73e0644 ac64cdc 73e0644 ac64cdc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import { query } from "$app/server";
import { withCache } from "$lib/utils/cache.js";
import typia from "typia";
type AvatarJson = {
avatarUrl: string;
};
export const getAvatarUrl = query(
typia.createValidate<string | undefined>(),
withCache(async (orgName): Promise<string | undefined> => {
if (!orgName) return;
const url = `https://huggingface.co/api/organizations/${orgName}/avatar`;
const res = await fetch(url);
if (!res.ok) {
throw new Error(`Error getting avatar url for org: ${orgName}`);
}
const json = await res.json();
typia.assert<AvatarJson>(json);
const { avatarUrl } = json;
return avatarUrl;
}),
);
|