MCPcopy Index your code
hub / github.com/fontsource/fontsource / updateAxisRegistry

Function updateAxisRegistry

api/metadata/src/variable/update.ts:59–83  ·  view source on GitHub ↗
(env: Env, ctx: ExecutionContext)

Source from the content-addressed store, hash-verified

57};
58
59export const updateAxisRegistry = async (env: Env, ctx: ExecutionContext) => {
60 const resp = await fetch(AXIS_REGISTRY_URL);
61 if (!resp.ok) {
62 const text = await resp.text();
63 throw new StatusError(
64 resp.status,
65 `Failed to fetch axis registry metadata. ${text}`,
66 );
67 }
68 const data = (await resp.json()) as AxisRegistryDownload;
69
70 const registry: AxisRegistry = {};
71 // Remove tag property from all fonts and use it as a key
72 for (const item of data) {
73 const { tag, ...rest } = item;
74 registry[tag] = rest;
75 }
76
77 // Save entire metadata into KV first
78 ctx.waitUntil(
79 env.METADATA.put(METADATA_KEYS.axisRegistry, JSON.stringify(registry)),
80 );
81
82 return registry;
83};

Callers 2

scheduledFunction · 0.90
getAxisRegistryFunction · 0.90

Calls 5

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

Tested by

no test coverage detected