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

Function getMetadata

api/common/util.ts:10–30  ·  view source on GitHub ↗
(id: string, req: Request, env: Env)

Source from the content-addressed store, hash-verified

8
9// Fetch latest metadata from metadata worker
10export const getMetadata = async (id: string, req: Request, env: Env) => {
11 const apiPathname = `/v1/fonts/${id}`;
12 const url = new URL(req.url);
13 url.pathname = apiPathname;
14
15 // Update incoming request to use new pathname
16 const newRequest = new Request(url.toString(), {
17 ...req.clone(),
18 method: 'GET',
19 });
20 const metadata = await env.METADATA.fetch(newRequest);
21 if (!metadata.ok) {
22 const error = await metadata.json<StatusErrorObject>();
23 throw new StatusError(
24 metadata.status,
25 `Bad response from metadata worker. ${error.error}`,
26 );
27 }
28
29 return await metadata.json<IDResponse>();
30};
31
32export const getVariableMetadata = async (
33 id: string,

Callers 1

router.tsFile · 0.90

Calls 3

toStringMethod · 0.80
cloneMethod · 0.65
fetchMethod · 0.65

Tested by

no test coverage detected