MCPcopy Create free account
hub / github.com/JacobLinCool/LeetCode-Stats-Card / generate

Function generate

packages/cloudflare-worker/src/handler.ts:17–41  ·  view source on GitHub ↗
(
    config: Record<string, string>,
    header: Record<string, string>,
)

Source from the content-addressed store, hash-verified

15});
16
17async function generate(
18 config: Record<string, string>,
19 header: Record<string, string>,
20): Promise<Response> {
21 let sanitized: Config;
22 try {
23 sanitized = sanitize(config);
24 } catch (err) {
25 return new Response((err as Error).message, {
26 status: 400,
27 });
28 }
29 console.log("sanitized config", JSON.stringify(sanitized, null, 4));
30
31 const cache_time = parseInt(config.cache || "300") ?? 300;
32 const cache = await caches.open("leetcode");
33
34 const generator = new Generator(cache, header);
35 generator.verbose = true;
36
37 const headers = new Header().add("cors", "svg");
38 headers.set("cache-control", `public, max-age=${cache_time}`);
39
40 return new Response(await generator.generate(sanitized), { headers });
41}
42
43// handle path variable
44app.get("/:username", async (c) => {

Callers 1

handler.tsFile · 0.70

Calls 5

generateMethod · 0.95
sanitizeFunction · 0.90
logMethod · 0.80
stringifyMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected