MCPcopy Create free account
hub / github.com/fontsource/fontsource / updateList

Function updateList

api/metadata/src/fontlist/update.ts:60–81  ·  view source on GitHub ↗
(
	key: FontlistQueries,
	env: Env,
	ctx: ExecutionContext,
)

Source from the content-addressed store, hash-verified

58
59// This updates the fontlist dataset for a given key
60const updateList = async (
61 key: FontlistQueries,
62 env: Env,
63 ctx: ExecutionContext,
64) => {
65 const response = await fetch(METADATA_URL);
66 const data = (await response.json()) as FontsourceMetadata;
67
68 // Depending on key, generate a fontlist object with respective values
69 const list: Fontlist = {};
70
71 // Rewrite variable object to boolean state
72 for (const value of Object.values(data)) {
73 list[value.id] = key === 'variable' ? Boolean(value.variable) : value[key];
74 }
75
76 // Store the list in KV
77 ctx.waitUntil(
78 env.METADATA.put(METADATA_KEYS.fontlist(key), JSON.stringify(list)),
79 );
80 return list;
81};
82
83export { updateList, updateMetadata };

Callers 2

scheduledFunction · 0.90
getListFunction · 0.90

Calls 5

jsonMethod · 0.80
valuesMethod · 0.80
waitUntilMethod · 0.65
putMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected